Jump to content

Cleanup.cmd not working properly


Recommended Posts

del "$$\System32\sleep.exe" 
del "$$\System32\cmdow.exe"

If i'm not mistaking, this code won't work. The $$ folder, once copied during setup, becomes %SystemRoot%.

So in order to delete these 2 files, imo you should use

del "%SystemRoot%\System32\sleep.exe" 
del "%SystemRoot%\System32\cmdow.exe"

If it works your way, no problem. Else, i think you should use my suggestion.

Link to comment
Share on other sites


With $$, I ment the Windows folder as it says on the Unattended site, but I just checked it out and you guys are right, explorer doesn't understand it (syntax error). I'll just use %systemdrive%\Windows\system32.

Anyway, Any more ideas on how I could solve this problem of mine?

Link to comment
Share on other sites

Sounds to me like this is happening.

Auto

1. windows cd setup

2. reboot

3. runonceex

4. not deleteing the folders/files

5. reboot

6. ready to go

Manual

1. windows cd setup

2. reboot

3. runonceex

4. not deleteing the folders/files

5. reboot

6. ready to go

7. run cleanup.cmd

8. files/folders deleted

I reckon add reboot in your cleanup.cmd and add another runonceex to run deletethebloodyfiles.cmd.

So

1. windows cd setup

2. reboot

3. runonceex

4. not deleteing the folders/files

5. reboot

6. run deletethebloodyfiles.cmd

8. files/folders deleted

9. reboot

10. ready to go

Whatcha think?

Link to comment
Share on other sites

Try the VBS script I left above in your runonce

Example

REG ADD %KEY% /V TITLE /D "The Install Section" /f

REG ADD %KEY%\000 /VE /D "Preparing Installation..." /f

REG ADD %KEY%\001 /VE /D "Wrar320ce" /f

REG ADD %KEY%\001 /V 1 /D "%CDROM%Apps\Winrar\WinRar.exe" /f

REG ADD %KEY%\003 /VE /D "SCD10en" /f

REG ADD %KEY%\003 /V 1 /D "%CDROM%Apps\SCD10en.exe /q" /f

REG ADD %KEY%\005 /VE /D "Preparing Clean Up" /f

REG ADD %KEY%\005 /V 1 /D "%CDROM%Apps\Cleanup.Vbs" /f

Save As CleanUp.vbs
Dim Act, AllDesk, All_UP, DelFile, DelFolder, Fso,  SD, Udesk, User_P

Set Act = CreateObject("Wscript.shell")

Set Fso = CreateObject("Scripting.FileSystemObject")

All_UP = Act.ExpandEnvironmentStrings("%Allusersprofile%")

User_P = Act.ExpandEnvironmentStrings("%UserProfile%")

SD = Act.ExpandEnvironmentStrings("%Systemdrive%")

AllDesk = All_UP & "\Start Menu\Programs"

Udesk = User_P & "\Start Menu\Programs"

'''' SHUT DOWN

Act.Run("shutdown.exe -t 25 -r -f -c ""Preparing To reboot"""), 1,True

'''' ARRAY FOR FILES TO DELETE

DelFile = Array(All_UP & "\Start Menu\Programs\Adobe Reader 6.0.3.lnk",All_UP & "\Desktop\*.*",_

User_P & "\Desktop\*.*",User_P & "\Start Menu\Programs\Remote Assistance.lnk",All_UP & "\Desktop\VLC media player.lnk",_

User_P & "\Desktop\Spybot - Search & Destroy.lnk",User_P & "\Desktop\Skype.lnk",User_P & "\Desktop\Notepad++.lnk",_

All_UP & "\Start Menu\Programs\Startup\Adobe Gamma Loader.lnk",User_P & "\Start Menu\Programs\Outlook Express.lnk",_

All_UP & "\Start Menu\Set Program Access and Defaults.lnk",All_UP & "\Start Menu\Windows Catalog.lnk",SD & "\autoexec.bat",_

SD & "\config.sys")

''''DELETES ALL THE FILES IN DELFILE

For Each StrFile In DelFile

If Fso.FileExists(StrFile) Then

Fso.DeleteFile(Chr(34) & StrFile & Chr(34))

Else On Error Resume Next

End If

Next

''''ARRAY TO DELETE FOLDERS

DelFolder = Array(AllDesk & "\Administrative Tools",AllDesk & "\Nvidia Corporation",AllDesk & "\7-Zip",_

AllDesk & "\Gaim",AllDesk & "\Mozilla Firefox",User_P & "\My Documents\My Music",User_P & "\My Documents\My Pictures",_

AllDesk & "\Accessories", All_UP & "\Start Menu\Accessories",User_P & "\Start Menu\Programs\Accessories",_

AllDesk & "\Nero",User_P & "\My Documents\My Skype Pictures",AllDesk & "\EA Games", AllDesk & "\Spybot - Search & Destroy",_

AllDesk & "\Skype",AllDesk & "\WinRAR",AllDesk & "\VideoLAN",Udesk & "\Powertoys for Windows XP",Udesk & "\XP Codec Pack 1.0.3",_

Udesk & "\Notepad++",Udesk & "\FirstClass",Udesk & "\Azureus",Udesk & "\foobar2000",Udesk & "\arniWORX",Udesk & "\TrackerV3",_

SD & "\Drivers",SD & "\temp",SD & "\D",User_P & "\My Documents\My Pictures\Sample Pictures",SD & "\Install")

''''DELETES THE FOLDERS

For Each StrFolder In DelFolder

If Fso.FolderExists(StrFolder) Then

Fso.DeleteFolder(Chr(34) & StrFolder & Chr(34))

Else On Error Resume Next

End If

Next

Link to comment
Share on other sites

I am also getting the same problem with the D folder and those pesky shortcuts (IE, OE and Address Book) in the start menu. I run them the exact same way you do and was also thinking of the .vbs route.

I think it doesn't get deleted because the DriverPack cleanup file that's supposed to do it is in the D folder itself. I mean, how can you delete the folder when the script that's deleting it is in the folder?? So, I stuck "RD /S /Q %systemdrive%\D" in my own cleanup script that runs right after the DriverPack one and it deletes it fine. :)

For the IE, OE and Address Book shortcuts in the start menu, I'm pretty sure those are created *after* the RunOnceEx scripts are ran. I think this because in my script I do "DIR /S /B C:\ > dir.txt" and they are not listed anywhere. To solve this I was thinking of putting a script in the Startup folder and then deleting it before reboot. Anyone else have suggestions?

Anyway, tell me how the .vbs script works out :)

Link to comment
Share on other sites

At The end of the runonce add this line, so when you restart it will

run the clean up.

Last Line Of The RunOnce

REG ADD %KEY%\470 /VE /D "Preparing Final Check clean Up"/f

REG ADD %KEY%\470 /V 1 /D "%systemdrive%\WINDOWS\cleanup.cmd"/f

CleanUp.cmd

This just a example use your own location, use a VBS file or Cmd

Echo Off && CLS && Color f2 && Mode 55,3 && Title Final Clean UP

SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx

REG ADD %KEY%\999/VE /D "Preparing For Final Clean Up"/f

REG ADD %KEY%\999 /V 1 /D "Wscript.exe %systemdrive%\WINDOWS\cleanup.Vbs"/f

Link to comment
Share on other sites

I tried it out with the cleanup.cmd once more and it didn't work. So, I did a little investigation and checked regedit. Guess what? The entry is there, but somehow, Windows doesn't execute it. I don't understand why. I've tried putting different numbers to rearrange the priority, but it didn't help a thing. I'm beggining to think that perhaps, I nLited my Windows a "little" to much and now, my Windows seems to be having some registry execution problems. Funny though, because it executes RunOnceEx.

I'm not sure about this, but what do you guys think? Also, what services/components are required for registry entries to work properly?

Link to comment
Share on other sites

Well, I finally solved it and as it turned out, it was a silly mistake of me. The thing is that I use BBlean, which replaces explorer at the time when it's run and stops RunOnceEx from running since explorer has to run for it to start. So, I simply rearranged the setup process so that my Blackbox installs in the end and now everything works.

Oh, I also had to combine 2 cleanup.cmd's to make it work since one didn't make it. I use the first one after the first restart. Then, this cleanup executes a file that places new information into RunOnceEx, telling it to execute Cleanup2.cmd after another restart. When the restart is done, Cleanup2.cmd executes and everything is gone. I tried using only cleanup.cmd after one restart, but it didn't remove everything since the "D" and "Install" folders were left.

So the setup order is like this:

1.RunOnceEx

2.Restart

3.Cleanup.cmd

4.Restart

5.Cleanup2.cmd & Blackbox

6.Restart

Well, thanks for your help anyway guys and I hope that this solves the problem for those of you that have the same problem as I did :thumbup.

Edited by Marthax
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...