October 3rd, 2002, 12:44 PM
Deleting Running Programs
In Windows 98, to delete a running program, a value can be put in the registry, HKLM\Software\Microsoft\Windows\Explorer\CurrentVersion\Runonce. This is a dos command line function. In the run directory it is command.com /c del "C:\[path][filename]". This works, and when the computer is rebooted, all files that are in the runonce registry key are deleted. This doesn't work in windows NT/2000/XP. The command line it the same, but it won't delete the files in the runonce registry key. I tried the same command line without the /c and that doesn't work. The del in the dos window has a different format. The one in 98 is del [drive][path][filename]. The one in XP is del [...][..[attributes]] names, and names it the filename. Is there a way to delete files in the dos window? The program is an installiation program, the program itself has to be removed the next time the computer is started.
October 5th, 2002, 07:05 AM
the format does not matter (here)
- does your "del" command work when you type it in the dos-window?
- did you supply the full path to command.com (i.e. "C:\WINDOWS\SYSTEM32\COMMAND.COM")
- did you try putting the whole entry into quotes?
for win2000 and XP there is a better way:
make your installer remove itself using MoveFileEx(), it will fail (since it is running). but it will be deleted on the next reboot. nice feature, eh?
October 7th, 2002, 07:18 AM
I typed the "del" command in a dos window and it worked. I typed hte full path to command.com" and there was no difference. The command.com works, there is an error in the dos window. The dos window displays:
specified COMMAND search directory bad
parameter format not correct
too many parameters
with command.com del "[drive][path][filename]" or "c:\windows\system32\command.com" del "[drive][path[filename]". I tried putting the whole thing in quotes and that didn't work either. The command is different than windows 95/98/ME, is it possible to use command line functions in the start menu\run program.
October 7th, 2002, 01:19 PM
So, go for the MoveFileEx() approach (it is a WinApi function)
October 11th, 2002, 06:34 AM
Will this work for 95/95/ME, or only 2000 and XP? It would make everything easier if it works for all windows versions.
October 11th, 2002, 11:03 AM
I tried the function, MoveFileEx(oldfilename, newfilename, NULL), on XP, but it didn't delete the files when I restarted. Shoud there be any flags set? Should this be MoveFile()?
October 11th, 2002, 11:46 AM
Set lpNewFileName to NULL and dwFlags to MOVEFILE_DELAY_UNTIL_REBOOT
(found here: http://msdn.microsoft.com/library/de...movefileex.asp )
it will only work for 2k and XP, for W9X you need to use your batch-file.
a lot would be easier if the two APIs weren´t that different
October 11th, 2002, 01:51 PM
There is a command in c++ that is supposed to delete files, and should delete files that are in use. The command is remove(). It deletes files, but it doesn't delete the file that the command is in, something that it is supposed to do. Is the information wrong about this command? The MoveFileEx() worked, but I want to see if there is a way that will work on all versions of windows.
October 11th, 2002, 03:12 PM
from my experience there is few (advanced) code that works for both... there´s a reason why MS is getting rid of W9X (no support anymore since 0106 afaik)
since you are a programmer too, some examples that might make you think:
- no PlugBlt() on W9X
- no SetWindowModeEx(WS_TRANSPARENT) on W9X
- coordinate space transformations: only very limited support on W9X (eg. no rotation of bitmaps by OS; w2K CAN DO...)
- limitation of bitmap sizes (16MB on W9X is 2666px x 2666px x 24bits)
- different behaviour on BeginPaint() and EndPaint()
...and so on.
i wish there never was a W9X. but on my current project i have to double about 20% of my functions to make my soft work on all of them...
anyone willing to share his experience?