balubeto Posted July 28, 2009 Posted July 28, 2009 (edited) HII wrote this RemovePending.vbs script used to delete multiple files at the end of a custom installation of Vista SP2 and, then, I inserted, in the SetupComplete.cmd file, the calls to this vbs script. Namely:Option ExplicitDim objFSO, objReg, objArgsDim objFile, objFolder, objSubFolderDim arrObjects, arrOldObjects, strKillConst HKEY_LOCAL_MACHINE = &H80000002Set objFSO = CreateObject("Scripting.FileSystemObject")Set objArgs = Wscript.ArgumentsSet objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\root\default:StdRegProv")objReg.GetMultiStringValue HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\Session Manager", "PendingFileRenameOperations", ArrOldObjectsIf isArray(arrOldObjects) Then strKill = Join(arrOldObjects, vbTab)If objArgs.Count = 0 Then Wscript.Echo "Script for scheduling files and folders for removal at next boot" & vbCrLf &_ "Syntax: RemovePending.vbs c:\folder" Wscript.QuitEnd IfIf objFSO.FolderExists(objArgs(0)) Then DeleteFolder objArgs(0)ElseIf objFSO.FileExists(objArgs(0)) Then KillObject(objArgs(0))Else Wscript.Echo "Can't find path: " & objArgs(0) Wscript.QuitEnd IfarrObjects = Split(strKill, vbTab)objReg.SetMultiStringValue HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\Session Manager", "PendingFileRenameOperations", ArrObjectsIf Err.number = 0 Then Wscript.Echo objArgs(0) & " was scheduled for removal at next boot."Else Wscript.Echo "Could not schedule object for removal" & vbCrLf & "Error: " & Err.Number & " " & Err.Description End IfPrivate Sub DeleteFolder(strFolder) Set objFolder = objFSO.GetFolder(strFolder) For Each objSubFolder In objFolder.SubFolders DeleteFolder(objSubFolder.Path) Next For Each objFile In objFolder.Files objFSO.GetFile(objFile).Attributes = 0 KillObject objFile.Path Next objFSO.GetFolder(strFolder).Attributes = 0 KillObject strFolderEnd SubSub KillObject(strObject) If Len(strKill) > 0 Then strKill = strKill & vbTab strKill = strKill & "\??\" & strObject strKill = strKill & vbTabEnd Suband, at the end of the SetupComplete.cmd file, I wrote:cscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Setup\Scriptscscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\setupact.logcscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Logs\DPX\setupact.logcscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Panther\setupact.logcscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Panther\UnattendGC\setupact.logcscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\setuperr.logcscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Logs\DPX\setuperr.logcscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Panther\setuperr.logcscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Panther\UnattendGC\setuperr.logshutdown /r /t 30I noticed, however, that some files not are deleted as the %windir%\setupact.log and %windir%\setuperr.log files and the %windir%\Setup\Scripts directory. Why?P.S: If, however, having finished the installation, I write one of the following commands (%windir%\Setup\Scripts\RemovePending.vbs %windir%\setupact.log or %windir%\Setup\Scripts\RemovePending.vbs %windir%\setuperr.log or %windir%\Setup\Scripts\RemovePending.vbs %windir%\Setup\Scripts )from the command prompt of the administrator, the next time that I restart Vista, these objects are removed as scheduled.THANKSBYE Edited July 28, 2009 by balubeto
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