sixpack Posted January 21, 2005 Author Share Posted January 21, 2005 i did test your cmd and it works great. thanks for this. Link to comment Share on other sites More sharing options...
Acheron Posted January 22, 2005 Share Posted January 22, 2005 Okay, slept well and thought about your request, it's a bit of a programming challenge, but I managed to work the delete on next reboot for files out DeleteFileonReboot.regWindows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\*\shell\Delete on reboot\command]@="delfile.cmd \"%1\""[HKEY_CLASSES_ROOT\*\shell\Open]delfile.cmd@echo offsetlocalset pathwithquotes=%1set originalpath=%pathwithquotes:~1,-1%REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v "Del %originalpath% OnNextReboot" /d "cmd.exe /c DEL /F /Q \"%originalpath%\"" /fendlocaldelfile.cmd goes into windir or system32[HKEY_CLASSES_ROOT\*\shell\Open] is for security, without it "Delete on Reboot" becomes the default action on all unknown files, ( no, that's not what you want ).Also fixed the code for the deletefolderonreboot tweak. It's faster. BTW, it won't work with special characters as % or & in filenames yet Link to comment Share on other sites More sharing options...
sixpack Posted January 22, 2005 Author Share Posted January 22, 2005 thanks hp38guser Link to comment Share on other sites More sharing options...
Acheron Posted January 22, 2005 Share Posted January 22, 2005 I stumbled with this one so it handles even filenames with special characters in it, not an easy task, because the batch instruction set is not very well documented:DeleteFileonReboot.regWindows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\*\shell\Delete on reboot\command]@="delfile.cmd \"%1\""[HKEY_CLASSES_ROOT\*\shell\Open]delfile.cmd@echo offsetlocal disableextensionsset pathwithquotes=%1setlocal enableextensionsREG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v "Del %pathwithquotes:~1,-1% OnNextReboot" /d ^"cmd.exe /c DEL /F /Q \"%pathwithquotes:~1,-1%\"^" /fendlocal--------------------------------------------------------------------------DeleteFolderonReboot.regWindows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\Folder\shell\Delete on reboot\command]@="delfile.cmd \"%1\""delfolder.cmd@echo offsetlocal disableextensionsset pathwithquotes=%1setlocal enableextensionsREG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v "Del %pathwithquotes:~1,-1% OnNextReboot" /d ^"cmd.exe /c RD /S /Q \"%pathwithquotes:~1,-1%\"^" /fendlocalIt's nearly the same. In fact, only difference is the command you type in the prompt Link to comment Share on other sites More sharing options...
sixpack Posted January 22, 2005 Author Share Posted January 22, 2005 THANKSedit: tested and works great... YAY!! Link to comment Share on other sites More sharing options...
Acheron Posted January 24, 2005 Share Posted January 24, 2005 Sixpack, look this: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\*\shell\Open][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\""No more need for cmd files on hd.This works on all files, even at those with special characters. Only exception for files and folders with %var% in it. Link to comment Share on other sites More sharing options...
sixpack Posted January 24, 2005 Author Share Posted January 24, 2005 going to try it tomorrowi did experiment with context menu dll's [got nice one's] so the registery is a little f***t upso i'll install windows and test it Link to comment Share on other sites More sharing options...
Acheron Posted January 24, 2005 Share Posted January 24, 2005 my guess is it cant be doneor there must be a dll someware that can do all thisbut give up, NEVER P.S %var% as in SET VAR=var:Examples:%systemdrive%%systemroot%%windir%%programfiles%%temp%%path%For a full list type SET in a command prompt. Link to comment Share on other sites More sharing options...
-Fox- Posted February 4, 2005 Share Posted February 4, 2005 Cool, this looks amazing Your making a file that when opend, the next time you reboot it deletes the specifid file yeah, when would the file specified be deleted? before or after your OS starts loading?Thanks you Link to comment Share on other sites More sharing options...
Acheron Posted February 4, 2005 Share Posted February 4, 2005 The files get removed when a user logs on to the system. So no critical Windows sytem files will get removed, but you can get rid of some files that are in use by some programs or the windows system Link to comment Share on other sites More sharing options...
jamesbebby Posted April 21, 2011 Share Posted April 21, 2011 (edited) I know this is an old post........but people do say 'use the search' I need to delete the temp folder on 'next reboot' through a CMD my install runs, i need to this because i need to clean the temp folder after my install.This works but as we know the temp folder are different from XP to Win7.@echo offsetlocal disableextensionsset pathwithquotes=%1setlocal enableextensionsREG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v "Del %"C:\Documents and Settings\???\Local Settings\Temp":~1,-1% OnNextReboot" /d ^"cmd.exe /c RD /S /Q \"%"C:\Documents and Settings\???\Local Settings\Temp":~1,-1%\"^" /fendlocalSo i try using the %TEMP% option so i will delete on both but it doesn't work@echo offsetlocal disableextensionsset pathwithquotes=%1setlocal enableextensionsREG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v "Del %"%TEMP%":~1,-1% OnNextReboot" /d ^"cmd.exe /c RD /S /Q \"%"%TEMP%":~1,-1%\"^" /fendlocalCan anyone help?EDIT- Sorted now.REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v NextReboot /d "cmd.exe /c RD /S /Q %TEMP%"Cheers, James Edited April 21, 2011 by jamesbebby Link to comment Share on other sites More sharing options...
Yzöwl Posted April 21, 2011 Share Posted April 21, 2011 @ jamesbebbyThere is no need to ever delete the %TEMP% directory, what you should be doing, although it shouldn't be necessary since your installer(s) should do it, is deleting specific files and /or folders within the %TEMP% location. Link to comment Share on other sites More sharing options...
jamesbebby Posted April 21, 2011 Share Posted April 21, 2011 (edited) Whats the command to delete all files & folders in the temp folder??? And not the temp folder itself.EDIT- I believe this is how people do itREG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v NextReboot /d "cmd.exe /c RD /S /Q %TEMP%"REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Currentversion\RunOnce /v NextReboot /d "cmd.exe /c MD /S /Q %TEMP%"Cheers, James Edited April 21, 2011 by jamesbebby Link to comment Share on other sites More sharing options...
Yzöwl Posted April 21, 2011 Share Posted April 21, 2011 There are some files and directories placed inside the Temp location for use by other some processes, they are not what you want to delete, so why do it?Your installers should remove their own temporary files as part of the installation routine. If they do not then the most responsible idea would be to remove all files and directories which have been added only by that routine. For that you would need to do either a before and after compare or ensure that the installation files are all placed within a unique directory which can then be deleted after installation without affecting others. You will then likely find that you will not be deleting any in use files since the ones you need to remove are not in use and they can be deleted with a simple command without rebooting. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now