SRJ Posted July 16, 2005 Share Posted July 16, 2005 Well, I can safely say I am becoming insane. All programs are copied to my %systemdrive% correctly and then installed correctly via RunOnceEx. The last command it runs is a compiled AutoIt script that places a RunOnceEx command to delete the copied $OEM$ directories and then forces a reboot. The problem is, nothing happens!!! The $OEM$ directories remain.I am using the following method for placing the key into RunOnceEx (I've tried both HKLM and HKCU but nothing is working ):RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx", "Cleanup Install", "REG_SZ", "cmd /C RD /S /Q %systemdrive%\install")The key does not delete upon reboot and nothing happens. I've also tried placing the key in RunOnce and despite it being removed upon reboot, the directory remains!!!!I've also tried running RD via CMDOW and also tried using XRD but to no avail.Here's something even more weird, if I place the key into the registry using REG ADD from runonceex.cmd it deletes nearly everything (there is a lock on one of the directories for some unknown reason).Can anyone help??? I'm at a loss as to why this is occurring... Link to comment Share on other sites More sharing options...
MHz Posted July 16, 2005 Share Posted July 16, 2005 Your %systemdrive% variable will not expand, as it is in a "Reg_sz" key.Use "Reg_Expand_sz" instead. Link to comment Share on other sites More sharing options...
SRJ Posted July 16, 2005 Author Share Posted July 16, 2005 Nope... no luck there. I tried replacing %systemdrive% with C: and still nothing happened. Any other ideas? Link to comment Share on other sites More sharing options...
Corn~Julio Posted July 17, 2005 Share Posted July 17, 2005 This Is What I Did I Inserted A Line In RunOnceEx To Run My Batch File At The End Of My Application Setup That Inserted These Lines Back Into RunOnceEx, Then Rebooted My PC & Deleted My Unwanted FoldersDel /Q Should Work For You, I Still Have Dos Frm Win98 Around, I'm Kinda Partial To ItSET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %KEY% /V TITLE /D "Deleteing Extra Setup Folders" /fREG ADD %KEY%\010 /VE /D "Delete Drivers Folder" /fREG ADD %KEY%\010 /V 1 /D "Deltree /Y C:\Drivers" /fREG ADD %KEY%\020 /VE /D "Delete Install Folder" /fREG ADD %KEY%\020 /V 1 /D "Deltree /Y C:\Install" /fshutdown.exe -r -f -t 60 -c "Reboot For Cleanup" Link to comment Share on other sites More sharing options...
DonDamm Posted July 17, 2005 Share Posted July 17, 2005 (edited) Batch files are much more reliable than trying to include a command in the RunOnceEx. Instead of cmd /C RD /S /Q %systemdrive%\installcreate a cleanup.cmd file with the RD command in it and then call the batch file. I call my batch file directly from the CD drive, so instead of %systemdrive% I use %cdrom% and use a For statement with all drive letters at the beginning of the RunOnceEx batch to identify the correct drive. This seems to work well and allows the cleanup of *any* stray folders or files on the system drive.In fact, check out Fritz_saxi's flash file for credits (in the MSFN forum) which you can run at the end during that final cleanup and 60 second wait before reboot. It's brilliant! ) Edited July 17, 2005 by DonDamm Link to comment Share on other sites More sharing options...
MHz Posted July 17, 2005 Share Posted July 17, 2005 cmd /C RD /S /Q %systemdrive%\installWell, I cannot fault this. It does work, as tested.I would possibly consider timing as the issue. Re-adding a entry into reononceex maybe failing? And an entry into runonce, which happens a split second after runonceex, maybe too early also. Something is still running? Which folder, or what file, would be a good clue.My last entry is an Autoit script, that is executed from the run key, waits for a program to launch, does some startmenu cleaning, that is not available in runonceex, deletes the run key, then deletes itself.Anyway, try to put this at the end of your autoit file. I would assume it is on the HDD also? This will delete the autoit file, then delete the install folder, by a created temporary batch file. The batch file loops with goto, until the items do not exist no more.Func OnAutoItExit() Local $cmdfile FileDelete(@TempDir & "\Scratch.bat") $cmdfile = ':loop' & @CRLF _ & 'del "' & @ScriptFullPath & '"' & @CRLF _ & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _ & ':folder' & @CRLF _ & 'rd /s /q %systemdrive%\Install' & @CRLF _ & 'if exist %systemdrive%\install goto folder' & @CRLF _ & 'del ' & @TempDir & '\Scratch.bat' FileWrite(@TempDir & "\Scratch.bat", $cmdfile) Run(@TempDir & "\Scratch.bat", @TempDir, @SW_HIDE)EndFunc Link to comment Share on other sites More sharing options...
gunsmokingman Posted July 17, 2005 Share Posted July 17, 2005 (edited) Here A VBS Script That Will Remove A Folder Called Install On %Systemdrive%Save As DelInstallFolder.vbsBlue Text Can Be Removed To Take Out The No Folder MsgboxRed Text Is The Stuff That get DeletedIf Createobject("Scripting.FilesystemObject").FolderExists("\Install") Then Createobject("Scripting.FilesystemObject").DeleteFolder("\Install") Else CreateObject("Wscript.Shell").popup "Folder Is Missing, Nothing To Delete", 3,"No Folder", 0 + 32 End IfIf Createobject("Scripting.FilesystemObject").FileExists("\DelInstallFolder.vbs") Then Createobject("Scripting.FilesystemObject").DeleteFile("\DelInstallFolder.vbs") End IfThis Write The Clean Up File Then Deletes The Folder And The FileSave As RmInstall.vbsDim Fso : Set Fso = Createobject("Scripting.FilesystemObject")Set TS = Fso.OpenTextFile("\DelInstallFolder.vbs",2,True)Ts.WriteLine "If Createobject(""Scripting.FilesystemObject"").FolderExists(""\Install"") Then Createobject(""Scripting.FilesystemObject"").DeleteFolder(""\Install"") Else CreateObject(""Wscript.Shell"").popup ""Folder Is Missing, Nothing To Delete"", 3,""No Folder"", 0 + 32 End If "Ts.WriteLine "If Createobject(""Scripting.FilesystemObject"").FileExists(""\DelInstallFolder.vbs"") Then Createobject(""Scripting.FilesystemObject"").DeleteFile(""\DelInstallFolder.vbs"") End If "Ts.closeCreateobject("Wscript.shell").Run("\DelInstallFolder.vbs") Edited July 17, 2005 by gunsmokingman Link to comment Share on other sites More sharing options...
SRJ Posted July 18, 2005 Author Share Posted July 18, 2005 Thanks guys... other events have taken me away from putting your replies into action (try like a logon stop error!!! aargghh - note to others, don't delete VGA Save drivers or you may find you can't access WinXP Pro at all, except without doing a repair over the top!!!)...Will let you know the outcome.. I think it is a timing issue but I'm not sure how to fix it but your comments above have provided some food for thought. 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