Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: WININIT.INI WININIT.EXE IntControl(30,...)
You can't do it directly. Basically you have to write a WININIT.INI file in the windows directory that is designed to take care of this. (Note that the WININIT.INI file is NOT an INI file (be careful) and as such cannot be reliably written to via the iniwritepvt function)
If you look at the WININIT.INI and .BAK files in your Windows directory you can figure out how this works.
If it is WinBatch trying to overwrite the DLL is use, we can handle it, but if it is another setup program trying to do it, some other solution must be found.
If you create a file called WININIT.INI in the Windows directory, files listed will be renamed during bootup. An example of what a WININIT.INI file might look like is:
[rename] C:\Fred\Fault.exe=C:\Fred\Fault.1
[rename] NULL=C:\Fred\Fault.exe
The following code will delete a file. if you change NUL to the new file name that will work. Short file names only are legal I think:
fn="c:\xxx.exe" if WinMetrics(-4)==4 ;NT ;the IntControl(30...) function only works in NT (wherein it makes a call to the ;"CreateFile" API for file deletion or copying when the file is free, or when a reboot occurs) IntControl(30,fn,"",0,0) endif if WinMetrics(-4)==5 ;95 wininitfile=strcat(DirWindows(0),"wininit.ini") if FileExist(wininitfile) ff=FileOpen(wininitfile,"APPEND") FileWrite(ff,strcat("NUL=",fn)) FileClose else ff=FileOpen(wininitfile,"WRITE") FileWrite(ff,"[rename]") FileWrite(ff,strcat("NUL=",fn)) FileClose endif endifFor 32 bit system this will delete the fn file at next reboot.
Under Win3x and Win9x you have the WININIT.INI file that can perform renames to the "NUL" device, thus deleting the files. You cannot, however, work with long file names when using WININIT.INI so be prepared to translate all file names to their short file names when making entries in this .INI file. Another gotcha is the syntax required to effect a file delete with this method. All entires go in a section named [Rename] and each entry is of the form "new-name=old-name". Unfortunately, deleting involves renaming the file to a name of "NUL". Since the .INI file management routines cannot handle duplicate keyword names in a section you have to cheat as follows to make it work:
[Rename] C:\TEMP\JUNKXXXXA.TMP=C:\PROGRA~1\MYFILES\WBDBS32I.DLL C:\TEMP\JUNKXXXXB.TMP=C:\PROGRA~1\MYFILES\WWWNT32I.DLL C:\TEMP\JUNKXXXXC.TMP=C:\PROGRA~1\MYFILES\MYSCRIPT.EXE NUL=C:\TEMP\JUNKXXXX.TMPSince the target names on the first 3 renames are 9 characters long the .INI file routines can create the entries OK and then WININIT.EXE promptly processes the target names as 8.3 names and strips the sequence characters (A,B,C...) off of the ends of the names. This results in all of the source files getting renamed to the same name and then that one file name gets deleted at the end. WININIT.EXE will rename the WININIT.INI file to WININIT.BAK after processing it.
Under WinNT you have functions available within WinBatch to set up delayed renames and deletes of files with IntControl(30,x,x,x,x).
Article ID: W13262
Filename: Delete Files after bootup using WinINIT.INI.txt
File Created: 2001:03:01:14:35:10
Last Updated: 2001:03:01:14:35:10