February 16, 200620 yr hi im having trouble using my clean up script to clean off some unwanted desktop icons and rerout my start menu programs,,the problem is my cleanup script is running before the desktop gets a chance to fully setup so the script runs before everthing is fully set so it has nothing to delete and reroute, then its set to auto matically restart the pc is there any way i can set the pc to restart after everything is finally set up , then have it in the cmd remember to run the cleanup script after the desktop is setup then delete it self ?
February 16, 200620 yr You could entry the files in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager under the REG_EXPAND_SZ value PendingFileRenameOperations. Then the files are deleted after next restart. Just google for the value name and you'll find enough explanations.Of course, you also could run a batch through runonceex, but I prefer first method, cause you don't need to call a batch with this. Edited February 16, 200620 yr by Doc Symbiosis
February 16, 200620 yr In the first cleanup cmd you copy a batch file into the startup folder of the user that automatically log's on.. the startup folder wil be loaded after the desktop, this is the way i worked around this problem..Greets!
February 19, 200620 yr I'm with AndreK on this one, but with a twist: I place a WinRAR SFX called Finish.exe in the All Users Startup folder ($OEM$\$Docs\All Users\Start Menu\Programs\Startup) that unpacks the .cmd file to the temp directory and runs it from there. The last line of the .cmd deletes the SFX from the Startup directory.Finish.exe WinRAR SFX Archive comment:Path=%windir%\TempSetup=cleanup.cmdSilent=1Overwrite=1Title=...cleanup.cmd:@ECHO OFF::Clean up Start Menu shortcutsSET AllStart=%systemdrive%\Documents and Settings\All Users\Start MenuSET AllDesk=%systemdrive%\Documents and Settings\All Users\DesktopDEL /F "%AllStart%\Set Program Access and Defaults.lnk"etc.DEL "%AllDesk%\WinZip.lnk"etc.RD /S /Q "%systemdrive%\blah\blah\blah"etc.ECHO Y | Del "%systemdrive%\WINDOWS\*.bmp"DEL "%systemdrive%\Documents and Settings\All Users\Start Menu\blah.lnk"etc.DEL /F "%systemdrive%\Documents and Settings\All Users\Start Menu\Programs\Startup\Finish.exe"CLSEXIT
February 20, 200620 yr Author I'm with AndreK on this one, but with a twist: I place a WinRAR SFX called Finish.exe in the All Users Startup folder ($OEM$\$Docs\All Users\Start Menu\Programs\Startup) that unpacks the .cmd file to the temp directory and runs it from there. The last line of the .cmd deletes the SFX from the Startup directory.Finish.exe WinRAR SFX Archive comment:Path=%windir%\TempSetup=cleanup.cmdSilent=1Overwrite=1Title=...cleanup.cmd:@ECHO OFF::Clean up Start Menu shortcutsSET AllStart=%systemdrive%\Documents and Settings\All Users\Start MenuSET AllDesk=%systemdrive%\Documents and Settings\All Users\DesktopDEL /F "%AllStart%\Set Program Access and Defaults.lnk"etc.DEL "%AllDesk%\WinZip.lnk"etc.RD /S /Q "%systemdrive%\blah\blah\blah"etc.ECHO Y | Del "%systemdrive%\WINDOWS\*.bmp"DEL "%systemdrive%\Documents and Settings\All Users\Start Menu\blah.lnk"etc.DEL /F "%systemdrive%\Documents and Settings\All Users\Start Menu\Programs\Startup\Finish.exe"CLSEXITyea blinktd that is what i tried also it works like a charm,, thanks for your advice unfortunatly ,, i thought that one up to the day i wrote this thread great minds think alike,
February 20, 200620 yr i had been trying to figure out a way to run cleanup propperly also. this method worked great. thanx all
March 30, 200620 yr Question though...Where does the Finish.exe get the .cmd file from in order to extract it to the temp folder?What are the 3 things at the end of this? Is that what I use or put a title there?Title=...
March 31, 200620 yr Just a quick follow up from me.Thanx to member Djé for this simple code that makes a batch file delete itself upon finishing.DEL /Q /F %0Hope it helps someonelse down the line. If so give the props to Djé. I'm just a 'LiL middle man.
April 1, 200620 yr Thanx to member Djé for this simple code that makes a batch file delete itself upon finishing.DEL /Q /F %0Almost You need to include in your batch.@echo offSetLocal enableextensions::Your cleanup code below here::Your cleanup code above heredel /q "%~f0"EndLocal
April 3, 200620 yr just adding DEL /Q /F %0Exitto the end of my .cmd file worked for me. I could of just got lucky, but 100% deleted itself. 5 different times or so now too.Just F.Y.I. because I dang sure can't dispute anyone let alone a 6 star MSFN Expert.
April 3, 200620 yr Actually since the running batch file isn't read-only or a global wildcard, you will only needdel %0as the last line of your script
June 6, 200719 yr I too reached the solution of copying a "cleanup2.bat" file to the startup folder.laze.
June 6, 200719 yr Old post to be sure, but I recall putting the .cmd into the WinRAR SFX (.exe format) because it would not run from Startup. Can't recall now . . . sounds like the batch file is all that is needed, thanks.
June 6, 200719 yr I create a user, that user logs in automatically, I place cleanup2.bat in the user's start-up folder.All Users does not work.laze.
June 7, 200719 yr Since this old thread has been resurrected (*I* didn't do it ), I hope someone can explain something to me. I've seen two lines that have been used to delete a currently running cmd file. I understand that DEL /Q /F %0 will DELete the current file (%0 referring to the 0th argument of the original cmd, or the file itself) Quietly (/Q) and Force the deletion even if it's a read-only file (/F).Then there's DEL /Q "%~f0" which appears to Quietly DELete (something). Obviously, that something is the current cmd file in this case, but how does the "%~f0" get parsed? I can see how "%0" would be better than %0 in case there are spaces in the file name. Is ~f equivelent to /F? Why is it included within the %0 argument? Does the second version do anything different from the first?I'd like to understand this for general knowledge purposes. I've written thousands of batch files in my life but I've never used the syntax of the second example. DEL /? doesn't even describe it.RayFYI: In case anyone shares my curiosity, I just tested adding quotes to %0 in a simple cmd file. To execute a cmd file with spaces in its name, you already had to enclose the file name in quotation marks ("test this.cmd" as opposed to test this.cmd). %0 already includes the quotation marks and enclosing it in additional quotation marks in the DEL command doesn't work ("%0" expands to ""test this""). So nevermind what I said about "%0" being an improvement over %0. It's not. Edited June 7, 200719 yr by NOTS3W
Create an account or sign in to comment