Fred_l | Code :
- RepDeBase = "c:\WMI_CLASSES\Scripts"
- SousRepDeBase = "c:\WMI_CLASSES\scripts\extraction"
- SousRepDeBaseLogs = "c:\WMI_CLASSES\Scripts\Logs"
- Set fso = CreateObject("Scripting.FileSystemObject" )
- If Not fso.FolderExists(RepDeBase) Then
- fso.CreateFolder(RepDeBase)
- End If
- If Not fso.FolderExists(SousRepDeBase) Then
- fso.CreateFolder(SousRepDeBase)
- End If
- If Not fso.FolderExists(SousRepDeBaseLogs) Then
- fso.CreateFolder(SousRepDeBaseLogs)
- End If
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2" )
- For Each objclass in objWMIService.SubclassesOf()
- intCounter=0
- If Left(objClass.Path_.Class,5) = "Win32" Then
- For Each Qualifier in objClass.Qualifiers_
- If UCase(Trim(Qualifier.Name)) = "ASSOCIATION" Then
- intCounter = 1
- End If
- Next
- If toto = 0 Then
- strComputer = "."
- Set objWMIService = GetObject ("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2" )
- Set strClass = objWMIService.Get(objClass.Path_.Class)
- Dim fso, MonFichierVbs
- Set fso = CreateObject("Scripting.FileSystemObject" )
- Set MonFichierVbs = fso.CreateTextFile(SousRepDeBase & chr(92) & objClass.Path_.Class & ".vbs", True)
- MonFichierVbs.WriteLine("On Error Resume Next" & VbCrLf)
- MonFichierVbs.WriteLine(" strComputer = "& chr(34) & "." & chr(34) & VbCrLf)
- MonFichierVbs.WriteLine("Set objFSO = CreateObject(" & chr(34) & "Scripting.FileSystemObject" & chr(34) & " )" )
- MonFichierVbs.WriteLine("Set objFile = objFSO.CreateTextFile(" & chr(34) & SousRepDeBaseLogs & chr(92) & objClass.Path_.Class & ".log" & chr(34) & " )" & VbCrLf)
- MonFichierVbs.WriteLine(" Set objWMIService = GetObject(" & chr(34) & "winmgmts:\\" & chr(34) & " & strComputer & " & chr(34) & "\root\cimv2" & chr(34) & " )" )
- MonFichierVbs.WriteLine(" Set colItems = objWMIService.ExecQuery(" & chr(34) & "Select * from" & " " & objClass.Path_.Class & chr(34) & ",,48)" & VbCrLf)
- CompteurPropriete = 0
- CompteurTotal = 0
- For each strItem in strClass.properties_
- CompteurPropriete = CompteurPropriete + 1
- 'wscript.echo strItem.name
- Next
- CompteurTotal = CompteurPropriete + CompteurTotal
- CompteurPropriete = 0
- 'For each strItem in strClass.properties_
- ' CompteurPropriete = CompteurPropriete + 1
- 'Next
- MonFichierVbs.WriteLine("" )
- MonFichierVbs.WriteLine(" For each objItem in colItems" & VbCrLf)
- CompteurPropriete = 0
- AppelFunctionDate = 0
- MonFichierVbs.WriteLine(" Set WshNetwork = WScript.CreateObject (" & chr(34) & "WScript.Network" & chr(34) & " )" )
- 'MonFichierVbs.WriteLine(" objFile.WriteLine " VBCRLF & VBCRLF & VBCRLF & chr(34) & "NomDuPoste = " & chr(34) & " & WshNetwork.ComputerName" )
- MonFichierVbs.WriteLine(" objFile.WriteLine VBCRLF & VBCRLF & VBCRLF " )
- MonFichierVbs.WriteLine(" MaDate = " & chr(34) & Date & chr(34) )
- MonFichierVbs.WriteLine(" MonHeure = " & chr(34) & Time & chr(34) )
- For each strItem in strClass.properties_
- CompteurPropriete = CompteurPropriete + 1
- If strItem.CIMType <> 101 Then
- MonFichierVbs.WriteLine(" objFile.WriteLine " & chr(34) & strItem.name & " = " & chr(34) & " & Cstr(objItem." & strItem.Name & " )" )
- End If
- If strItem.CIMType = 101 And CompteurPropriete <> CompteurTotal Then
- MonFichierVbs.WriteLine(" objFile.WriteLine " & chr(34) & strItem.name & " = " & chr(34) & " & TriVracDate(objItem." & strItem.name & " )" )
- End If
- If strItem.CIMType = 101 Then
- AppelFunctionDate = 1
- End If
- If AppelFunctionDate = 1 And CompteurPropriete = CompteurTotal Then
- MonFichierVbs.WriteLine(VbCrLf & " Next" & VbCrLf)
- MonFichierVbs.WriteLine(" Function TriVracDate(CaDate)" & VbCrLf)
- MonFichierVbs.WriteLine(" TriVracDate = (Left(CaDate, 4) & " & chr(34) & "/" & chr(34) & " & Mid(CaDate, 5, 2) & " & chr(34) & "/" & chr(34) & " & Mid(CaDate, 7, 2) & _" )
- MonFichierVbs.WriteLine(" " & chr(34) & " - (" & chr(34) & " & (Mid(CaDate, 9, 2) & " & chr(34) & ":" & chr(34) & " & Mid(CaDate, 11, 2) & " & chr(34) & ":" & chr(34) & " & Mid(CaDate, 13, 2))) & " & chr(34) & " )" & chr(34) & VbCrLf)
- MonFichierVbs.WriteLine(" End Function" & VbCRLf)
- Else
- If AppelFunctionDate <> 1 And CompteurPropriete = CompteurTotal Then
- MonFichierVbs.WriteLine(VbCrLf & " Next" & VbCrLf)
- End If
- End If
- Next
- End If
- End If
- Next
- MonFichierVbs.Close
- Set objShell = WScript.CreateObject("WScript.Shell" )
- Set folder = FSO.GetFolder(SousRepDeBase)
- Set file = Folder.files
- For each file In folder.Files
- If file.name <> "Win32_ActionCheck.vbs" and file.name <> "Win32_CheckCheck.vbs" and file.name <> "Win32_LogicalFileSecuritySetting.vbs" & _
- file.name <> "Win32_SecuritySetting.vbs" and file.name <> "Win32_SecuritySettingOfLogicalFile.vbs" and file.name <> "Win32_SecuritySettingOfObject.vbs" and & _
- file.name <> "Win32_ManagedSystemElementResource.vbs" and file.name <> "Win32_MethodParameterClass.vbs" and & _
- file.name <> "Win32_SoftwareElementAction.vbs" Then
- Result = ObjShell.run (SousRepDeBase & "\" & file.name,1,TRUE)
- End If
- Next
- wscript.echo "End run all VBS"
|
Voici un script qui liste tous les objet WMI, qui fait pour chaque Objet un VBS et qui lance les VBS Créés.
Ainsi tu as tous les paramêtres des objets...
J'espère que tu trouvera ton bonheure....
Fred
|