CIAO
Ho scritto questo script RemovePending.vbs che serve per cancellare vari file alla fine di un'installazione personalizzata di Vista SP2 e, poi, ho inserito, nel file SetupComplete.cmd, delle chiamate verso tale script vbs . Ossia:
ed, alla fine del file SetupComplete.cmd, ho scritto:codice:Option Explicit Dim objFSO, objReg, objArgs Dim objFile, objFolder, objSubFolder Dim arrObjects, arrOldObjects, strKill Const HKEY_LOCAL_MACHINE = &H80000002 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objArgs = Wscript.Arguments Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\root\default:StdRegProv") objReg.GetMultiStringValue HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\Session Manager", "PendingFileRenameOperations", ArrOldObjects If 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.Quit End If If 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.Quit End If arrObjects = Split(strKill, vbTab) objReg.SetMultiStringValue HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\Session Manager", "PendingFileRenameOperations", ArrObjects If 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 If Private 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 strFolder End Sub Sub KillObject(strObject) If Len(strKill) > 0 Then strKill = strKill & vbTab strKill = strKill & "\??\" & strObject strKill = strKill & vbTab End Sub
Ho notato, pero`, che alcuni file non vengono cancellati come i file %windir%\setupact.log e %windir%\setuperr.log e la directory %windir%\Setup\Scripts . Come mai?codice:cscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Setup\Scripts cscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\setupact.log cscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Logs\DPX\setupact.log cscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Panther\setupact.log cscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Panther\UnattendGC\setupact.log cscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\setuperr.log cscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Logs\DPX\setuperr.log cscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Panther\setuperr.log cscript %windir%\Setup\Scripts\RemovePending.vbs %windir%\Panther\UnattendGC\setuperr.log shutdown /r /t 30
GRAZIE
CIAO
P.S: Se, pero`, dopo aver finito l'installazione, scrivo uno dei seguenti comandi (%windir%\Setup\Scripts\RemovePending.vbs %windir%\setupact.log o %windir%\Setup\Scripts\RemovePending.vbs %windir%\setuperr.log o %windir%\Setup\Scripts\RemovePending.vbs %windir%\Setup\Scripts ) dal prompt dei comandi dell'amministratore, al successivo riavvio di Vista, questi oggetti vengono cancellati come avevo programmato.

Rispondi quotando