Jump to content

Cleanup.cmd not working properly


Recommended Posts

Hi everyone!

I have been inactive for like 2 months on this forum since I've been busy building my new righ, but now I'm back (and it feels great :P ).

Anyway, I have a small problem. When I execute my Cleanup file, I want it to delete 2 folders, "D" (created by BTS Packs) and "Install" (where all my installation files are kept).

It does delete everything except one folder inside the Install folder (Office2k3, one file remains here also) and one file in the "D" folder (Watchdriverpolicy.exe, or something like that). When I restart the computer and execute the cmd file manually, it deletes these files. However, if I do the same thing, but unattended, it doesn't delete them.

Why is that? I mean, I see the cleanup file get executed, but the folders are still there. I've tried many different methods when timing this file, but with no success.

Anyone who knows how I could solve this?

Thanks!

Marthax

Link to comment
Share on other sites


Maybe you should terminate the process before deleting the folder (seems to me the file is still in use when you try to delete it).

taskkill.exe /F /IM Watchdriverpolicy.exe
RD /S /Q %systemdrive%\Install\

Hope this helps.

Link to comment
Share on other sites

Her try this vbs file

Dim Act : Set Act = CreateObject("Wscript.Shell")

Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")

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

strComputer = "."

Set objWMIService = GetObject _

    ("winmgmts:\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery _

    ("Select * from Win32_Process Where Name = 'Watchdriverpolicy.exe'")

For Each objProcess in colProcessList

    objProcess.Terminate()

Next

If Fso.FolderExists(SD & "\Install") Then

Fso.DeleteFolder(SD & "\Install")

Else

Act.Popup "Cannot Delete This Folder" , 5, "Delete Error", 0 + 32

End If

Edited by gunsmokingman
Link to comment
Share on other sites

No, it's not that. Maybe I was a bit unclear. If I do it manually, it works. That is, if I execute the cleanup.cmd by hand, it deletes the files, while if I do the same thing, but let RunOnceEx do it, it doesn't get deleted. Why is this?

Link to comment
Share on other sites

No, it's not that. Maybe I was a bit unclear. If I do it manually, it works. That is, if I execute the cleanup.cmd by hand, it deletes the files, while if I do the same thing, but let RunOnceEx do it, it doesn't get deleted. Why is this?

RunOnceEx.

Edited by Marthax
Link to comment
Share on other sites

Actually, I have that same problem getting rid of the link for outlook express and Internet explorer in the "all programs" menu. I just assumed that windows re-added them @ bootup, kinda like the "Startup" folder in "all programs". Hopefully someone can help us!!! ;)

Link to comment
Share on other sites

Hopefully, yes :)

EDIT: If it makes the whole thing easier, then here's my Cleanup.cmd:

cmdow /hid
@echo off

shutdown -f -r -t 25 -c "The computer will restart within 25 seconds"

del "%Allusersprofile%\Start Menu\Programs\Adobe Reader 6.0.3.lnk"
del "%Allusersprofile%\Desktop\*.*" /Q
del "%Userprofile%\Desktop\*.*" /Q
del "%UserProfile%\Start Menu\Programs\Remote Assistance.lnk"
del "%AllUsersProfile%\Desktop\VLC media player.lnk"
del "$$\System32\sleep.exe"
del "$$\System32\cmdow.exe"
del "%Userprofile%\Desktop\Spybot - Search & Destroy.lnk"
del "%Userprofile%\Desktop\Skype.lnk"
del "%Userprofile%\Desktop\Notepad++.lnk"
del "%AllUsersProfile%\Start Menu\Programs\Startup\Adobe Gamma Loader.lnk"
del "%UserProfile%\Start Menu\Programs\Outlook Express.lnk"
del "%AllUsersProfile%\Start Menu\Set Program Access and Defaults.lnk"
del "%AllUsersProfile%\Start Menu\Windows Catalog.lnk"
del "%systemdrive%\autoexec.bat"
del "%systemdrive%\config.sys"

rd "%AllUsersProfile%\Start Menu\Programs\Administrative Tools" /S /Q
rd "%AllUsersProfile%\Start Menu\Programs\Nvidia Corporation" /S /Q
rd "%AllUsersProfile%\Start Menu\Programs\7-Zip" /S /Q
rd "%AllUsersProfile%\Start Menu\Programs\Gaim" /S /Q
rd "%AllUsersProfile%\Start Menu\Programs\Mozilla Firefox" /S /Q
rd "%Userprofile%\My Documents\My Music" /S /Q
rd "%Userprofile%\My Documents\My Pictures" /S /Q
rd "%AllUsersprofile%\Start Menu\Programs\Accessories" /S /Q
rd "%allUsersprofile%\Start Menu\Accessories" /S /Q
rd "%Userprofile%\Start Menu\Programs\Accessories" /S /Q
rd "%AllUsersProfile%\Start Menu\Programs\Nero" /S /Q
rd "%Userprofile%\My Documents\My Skype Pictures" /S /Q
rd "%AllUsersProfile%\Start Menu\Programs\EA Games" /S /Q
rd "%AllUsersProfile%\Start Menu\Programs\Spybot - Search & Destroy" /S /Q
rd "%AllUsersProfile%\Start Menu\Programs\Skype" /S /Q
rd "%AllUsersProfile%\Start Menu\Programs\WinRAR" /S /Q
rd "%AllUsersProfile%\Start Menu\Programs\VideoLAN" /S /Q
rd "%UserProfile%\Start Menu\Programs\Powertoys for Windows XP" /S /Q
rd "%UserProfile%\Start Menu\Programs\XP Codec Pack 1.0.3" /S /Q
rd "%UserProfile%\Start Menu\Programs\Notepad++" /S /Q
rd "%UserProfile%\Start Menu\Programs\FirstClass" /S/Q
rd "%UserProfile%\Start Menu\Programs\Azureus" /S /Q
rd "%UserProfile%\Start Menu\Programs\foobar2000" /S /Q
rd "%UserProfile%\Start Menu\Programs\arniWORX" /S /Q
rd "%UserProfile%\Start Menu\Programs\TrackerV3" /S /Q
rd "%Systemdrive%\Drivers" /S /Q
rd "%Systemdrive%\temp" /S /Q
rd "%Systemdrive%\D" /S /Q
rd "%Userprofile%\My Documents\My Pictures\Sample Pictures" /S /Q
rd "%Systemdrive%\Install" /S /Q
rd "%Systemdrive%\D" /S /Q







DEL %0

Edited by Marthax
Link to comment
Share on other sites

I was bored and redid Marthax Cleanup.cmd in a VBS Script to show

the differences between the 2.

This shows only the shutdown dialog, the delete file and folders are silent.

Green Text are the arrays for file and folders

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

Edited by gunsmokingman
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...