#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Posts
    9
    Rep Power
    0

    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.

    Craig
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    191
    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?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Posts
    9
    Rep Power
    0
    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.

    Craig
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    191
    So, go for the MoveFileEx() approach (it is a WinApi function)
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Posts
    9
    Rep Power
    0
    Will this work for 95/95/ME, or only 2000 and XP? It would make everything easier if it works for all windows versions.

    Craig
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Posts
    9
    Rep Power
    0
    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()?

    Craig
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    191
    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
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Posts
    9
    Rep Power
    0
    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.

    Craig
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    191
    dunno.
    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?

IMN logo majestic logo threadwatch logo seochat tools logo