Option Explicit Dim wshshell,fso,i,Fnct Dim strPath,strSystemFolder,strWinFolder,strTempFolder '----------------------------- Objekte erzeugen -------------------------------- i = 0 On Error Resume Next Do err.Clear i = i+1 Set wshshell = CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") Set Fnct = CreateObject("Install.Functions") WScript.Sleep 1000 Loop Until Err.Number = 0 OR i > 30 If Err.Number <> 0 Then WScript.Quit End If On Error Goto 0 '--------------------------- Standardpfade ------------------------------------- strPath = GetCurrentPath() strSystemFolder = fso.GetSpecialFolder(1) & "\" strWinFolder = fso.GetSpecialFolder(0) & "\" strTempFolder = fso.GetSpecialFolder(2) & "\" '------------------------------ Main ------------------------------------------- Dim strBatch Call SearchAllFoldersForPqiAndChangeAcl("d:\",1) Call SearchAllFoldersForPqiAndChangeAcl("e:\",1) If Len(strBatch) = 0 Then WScript.Quit End If Dim strBatchFile Dim Batchfile strBatchFile = strTempFolder & "\batch.bat" Set Batchfile = fso.OpenTextFile(strBatchFile,2,true) Call BatchFile.Write(strBatch) BatchFile.Close If fso.FileExists(strBatchFile) Then Call wshshell.Run("""" & strBatchFile & """",0,True) WScript.Sleep(1000) Call fso.DeleteFile(strBatchFile,True) End If '------------------------------- Funktionen ------------------------------------ Function GetCurrentPath() Dim l_strScriptName Dim l_strTemp l_strScriptName = WScript.ScriptFullName l_strTemp = WScript.ScriptName GetCurrentPath = Left(l_strScriptName, Len(l_strScriptName) - Len(l_strTemp)) End Function Function ExpandPath(p_strEnvironment,p_strDefault) Dim l_strTemp l_strTemp = wshshell.ExpandEnvironmentStrings(p_strEnvironment) If l_strTemp = p_strEnvironment Then l_strTemp = p_strDefault End If ExpandPath = l_strTemp End Function 'Durchsucht alle Ordner nach pqi-Dateien und ändert die Rechte Sub SearchAllFoldersForPqiAndChangeAcl(strStartFolder,nDepth) if (nDepth<5) Then SearchPqiFilesAndModifyAcl(strStartFolder) Dim Folder Dim AllSubfolders Dim Subfolder ' Es kann passieren, dass es wegen fehlender Zugriffsrechte ' zu einem Fehler kommt On Error Resume Next Set Folder = fso.GetFolder(strStartFolder) Set AllSubfolders = Folder.Subfolders ' ... in diesem Fall wird die Abarbeitung beendet If Err.number <> 0 Then err.Clear Exit Sub End If On Error Goto 0 On Error Resume Next For Each Subfolder in AllSubfolders If err.Number = 0 Then Call SearchAllFoldersForPqiAndChangeAcl(Subfolder,nDepth+1) End If Next On Error Goto 0 End If End Sub 'Sucht innerhalb eines Ordners nach Pqi-Dateien und ändert die Rechte Sub SearchPqiFilesAndModifyAcl(strFolder) Dim Folder Dim AllFiles Dim File If fso.FolderExists(strFolder) Then Set Folder = fso.GetFolder(strFolder) Set AllFiles = Folder.Files On Error Resume Next For Each File in AllFiles Dim strFilename strFilename = File.Name strFilename = LCase(strFilename) If Instr(strFilename,".pqi") <> 0 OR Instr(strFilename,".002") <> 0 OR Instr(strFilename,".tib") <> 0 Then 'MsgBox strFilename Dim strCommand Dim strFilenameWithPath Dim strRunas strFilenameWithPath = fso.BuildPath(strFolder,strFilename) strCommand = "xcacls.exe " & strFilenameWithPath & "/E /G Everyone:F;F /Y" Call wshshell.Run(strCommand,0,True) strRunas = strPath & "FockeRunAs.exe FockeAdmin !Gemini " & """" & strPath & "acl.bat " & strFilenameWithPath & """" strBatch = strBatch & strRunas & vbNewLine strRunas = strPath & "FockeRunAs.exe Focke Gemini " & """" & strPath & "acl.bat " & strFilenameWithPath & """" strBatch = strBatch & strRunas & vbNewLine End If Next On Error Goto 0 End If End Sub