C
cwp
This is less of a BAT file question, more of an OS question I think....
BAT files can delete themselves. This is really handy to clean up
after execution. To test this works is simple enough:
C:\test_dir>echo del runme.bat > runme.bat
C:\test_dir>type runme.bat
del runme.bat
C:\test_dir>runme.bat
C:\test_dir>del runme.bat
The batch file cannot be found. <<< this is OK
C:\test_dir>type runme.bat
The system cannot find the file specified.
C:\test_dir>
On a recent Windows XP box that I came across in a company, the above
doesn't work! Explorer.EXE "locks" the BAT file and the file doesn't
delete. If you try manually deleting, even through Windows GUI, the
error is "Access is denied". If you kill explorer.exe, the file
suddenly disappears (same for a reboot).
The strange thing is this "standard operating environment" of Windows
XP used to work fine for bat files to self-delete. The only change as
far as I can tell is that the new XP box used sysprep to get built
(which changes reg settings I think).
Is there any reg keys / system settings that could possibly stop bat
files from self-deleting??
BAT files can delete themselves. This is really handy to clean up
after execution. To test this works is simple enough:
C:\test_dir>echo del runme.bat > runme.bat
C:\test_dir>type runme.bat
del runme.bat
C:\test_dir>runme.bat
C:\test_dir>del runme.bat
The batch file cannot be found. <<< this is OK
C:\test_dir>type runme.bat
The system cannot find the file specified.
C:\test_dir>
On a recent Windows XP box that I came across in a company, the above
doesn't work! Explorer.EXE "locks" the BAT file and the file doesn't
delete. If you try manually deleting, even through Windows GUI, the
error is "Access is denied". If you kill explorer.exe, the file
suddenly disappears (same for a reboot).
The strange thing is this "standard operating environment" of Windows
XP used to work fine for bat files to self-delete. The only change as
far as I can tell is that the new XP box used sysprep to get built
(which changes reg settings I think).
Is there any reg keys / system settings that could possibly stop bat
files from self-deleting??