Just a quick one today, have you ever had a directory they just wouldn’t delete and you didn’t want to have to try downloading some crappy tool to do it for you on reboot?
Well I have and here is my solution… We are going to add an option to the right click contextual menu on Windows XP Pro, though this should work with any version of XP, and if it doesn’t oh well…
Fire up your favorite text editor, vi is highly recommend or ultraedit if stuck on Windows. Create a file called something like Sendto.reg with the contents of;
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Delete on Reboot\command]
@=”CMD /E:OFF /C REG ADD HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\Currentversion\\RunOnce /v \”Del %1 OnNextReboot\” /d ^\”cmd.exe /c DEL /F /Q \\\”%1\\\”\” /f\””
[HKEY_CLASSES_ROOT\Folder\shell\Delete on Reboot\command]
@=”CMD /E:OFF /C REG ADD HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\Currentversion\\RunOnce /v \”Del %1 OnNextReboot\” /d ^\”cmd.exe /c RD /S /Q \\\”%1\\\”\” /f\””
Now save the file, and merge it into your registry. Now you should have the option “Delete on Reboot” in your right click contextual menu. Now this is not all encompassing but works for most things. The gotcha’s you need to know about are it will only work if you log in again as the same user as it processes as a run once command for that user just after login but before the shell is loaded.
If the directory is being locked at the system level it won’t remove it as well the system will already have locked it by the time the users is enacted. However this works for 90% of the instances where this issue seems to crop up.
Enjoy, and as always if you aren’t comfortable playing in the registry, simple don’t and get an adult to supervise you 🙂