1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
'#############################################################################################################################################
'# PROJET ToTo - Client X #
'# #
'# InfoPosteUser 1.0 (01/06/2016) #
'# Matmat94 #
'# #
'#############################################################################################################################################
'On Error Resume Next
If WScript.Arguments.length =0 Then
Set objShell = CreateObject("Shell.Application")
'Pass a bogus argument with leading blank space, say [ uac]
objShell.ShellExecute "wscript.exe", Chr(34) & _
WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
End if
If WScript.Arguments.length =1 Then
REM ************************************** Récupération Date & Heure au lancement du script **************************************************
TimeWriteStart = Now() '*
writeXMLTIME TimeWriteStart, "Start" '*
REM ********************************************************* Fin ****************************************************************************
REM ************************************** Récupération Taille du dossier temporaire d'IE ****************************************************
Dim oSTIE,sTIE,sTIEShell,sUserProfile
Set oSTIE = CreateObject("Scripting.FileSystemObject")
Set sTIEShell = CreateObject("WScript.Shell")
sUserProfile = sTIEShell.ExpandEnvironmentStrings("%USERPROFILE%\AppData\Local\Microsoft\Windows\Temporary Internet Files")
If oSTIE.FolderExists(sUserProfile) Then
Set sTIE = oSTIE.GetFolder(sUserProfile)
'"Attributes :" & oFld.Attributes & vbCrlf & _
'"DateCreated :" & oFld.DateCreated & vbCrlf & _
'"DateLastAccessed :" & oFld.DateLastAccessed & vbCrlf & _
'"DateLastModified :" & oFld.DateLastModified & vbCrlf & _
'"Drive :" & oFld.Drive & vbCrlf & _
'"Name :" & oFld.Name & vbCrlf & _
'"ParentFolder :" & oFld.ParentFolder & vbCrlf & _
'"Path :" & oFld.Path & vbCrlf & _
'"ShortName :" & oFld.ShortName & vbCrlf & _
'"ShortPath :" & oFld.ShortPath & vbCrlf & _
'"Size :" & oFld.Size & vbCrlf & _
'"SubFolders.Count :" & oFld.SubFolders.count & vbCrlf & _
'"Type :" & oFld.Type
writeXMLSizeTempIE sTIE.Size
End If
REM ************************************** \Récupération Taille du dossier temporaire d'IE ***************************************************
REM ************************************** Récupération Taille du dossier Windows Temp *******************************************************
Dim sWinTemp 'Nom du Fichier a tester
Dim oSWT,sWT
Set oSWT = CreateObject("Scripting.FileSystemObject")
sWinTemp = "c:\Windows\Temp"
If oSWT.FolderExists(sWinTemp) Then
Set sWT = oSWT.GetFolder(sWinTemp)
'"Attributes :" & sWT.Attributes & vbCrlf & _
'"DateCreated :" & sWT.DateCreated & vbCrlf & _
'"DateLastAccessed :" & sWT.DateLastAccessed & vbCrlf & _
'"DateLastModified :" & sWT.DateLastModified & vbCrlf & _
'"Drive :" & sWT.Drive & vbCrlf & _
'"Name :" & sWT.Name & vbCrlf & _
'"ParentFolder :" & sWT.ParentFolder & vbCrlf & _
'"Path :" & sWT.Path & vbCrlf & _
'"ShortName :" & sWT.ShortName & vbCrlf & _
'"ShortPath :" & sWT.ShortPath & vbCrlf & _
'"Size :" & sWT.Size & vbCrlf
'"Type :" & sWT.Type
writeXMLSizeWinTemp sWT.Size
End If
REM ************************************** \Récupération Taille du dossier Windows Temp ******************************************************
REM ************************************** Récupération Espace Disque Logic ******************************************************************
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItemsLogicalDisk = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk",,48)
FreeSpaceDisk = ""
SizeDisk = ""
NameDisk = ""
Description = ""
For Each objItemDisk in colItemsLogicalDisk
NameDisk = objItemDisk.Name
FreeSpaceDisk = objItemDisk.FreeSpace
SizeDisk = objItemDisk.Size
Description = objItemDisk.Description
writeXMLDISK FreeSpaceDisk,SizeDisk,NameDisk
Next
Set objWMIService = Nothing
REM ************************************** \Récupération Espace Disque Local *******************************************************************
REM ************************************** Récupération Information Sécurité *******************************************************************
arrCat = Array("AntiVirus","Firewall","AntiSpyware")
arrNbr = Array(0,0,0)
Set objWMIService_AV = GetObject("winmgmts:\\.\root\SecurityCenter")
If Not IsNull (objWMIService_AV) Then
For a = LBound(arrCat, 1) To UBound(arrCat, 1)
Set colItems = objWMIService_AV.ExecQuery("Select * from " & arrCat(a) & "Product")
For Each objAVP In colItems
productEnabled = "0"
If objAVP.onAccessScanningEnabled Then productEnabled = "1"
productUptoDate = "0"
If objAVP.productUptoDate Then productUptoDate = "1"
writeXML "1", arrCat(a), objAVP.companyName, objAVP.displayName, objAVP.versionNumber, productEnabled, productUptoDate
arrNbr(a) = arrNbr(a) + 1
Next
Next
End If
Set objWMIService_AV = Nothing
Set objWMIService_AV = GetObject("winmgmts:\\.\root\SecurityCenter2")
if Not IsNull (objWMIService_AV) Then
For a = LBound(arrCat, 1) To UBound(arrCat, 1)
Set colItems2 = objWMIService_AV.ExecQuery("Select * from " & arrCat(a) & "Product")
For Each objAVP In colItems2
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshProcessEnv = WshShell.Environment("Process")
exe = objAVP.PathToSignedProductExe
exe = Replace(exe,"%ProgramFiles%",WshProcessEnv("ProgramFiles"))
If Mid(exe,1,1) = """" Then
Max = 2
While (Mid(exe,Max,1) <> """") And (Max <> Len(exe) )
Max = Max + 1
Wend
exe = Mid(exe,2,Max-2)
End If
exe = Replace(exe,"\","\\")
strCompanyName = ""
strVersionNumber = ""
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colFiles = objWMIService.ExecQuery ("Select * from CIM_Datafile Where name = '" & exe & "'")
If colFiles.Count = 0 Then
exe = Replace (exe," (x86)","")
Set colFiles = objWMIService.ExecQuery ("Select * from CIM_Datafile Where name = '" & exe & "'")
End If
For Each itemFile In colFiles
strCompanyName = (itemFile.Manufacturer)
strVersionNumber = (itemFile.Version)
Next
productEnabled = "0"
If Mid(dec2bin(objAVP.ProductState),12,1) = "1" Then productEnabled = "1"
productUptoDate = "0"
If Mid(dec2bin(objAVP.ProductState),16,8) = "00000000" Then productUptoDate = "1"
Set colItemsLogicalDisk = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk",,48)
FreeSpaceDisk = ""
SizeDisk = ""
For Each objItemDisk in colItemsLogicalDisk
FreeSpaceDisk = objItemDisk.FreeSpace
SizeDisk = objItemDisk.Size
Next
writeXML "2", arrCat(a), strCompanyName, objAVP.displayName, strVersionNumber, productEnabled, productUptoDate
arrNbr(a) = arrNbr(a) + 1
Next
Next
End If
Set objWMIService_AV = Nothing
REM ************************************** \Récupération Information Sécurité *******************************************************************
REM ######################################################## Test Pause : 5000 ############################
'Set WScript = CreateObject("WScript.Shell")
'WScript.Sleep 5000
REM ######################################################## Fin Test Pause : 5000 ########################
REM ************************************** Récupération de la date a la fin du script ****************************************************
TimeWriteEnd = Now()
writeXMLTIME TimeWriteEnd, "END"
writeXMLTIMEDIFF TimeWriteStart, TimeWriteEnd
REM ************************************** Récupération de la date a la fin du script ****************************************************
End If
Sub writeXML(scSCV,scCat,scComp,scProd,scVer,scEna,scDate)
Wscript.Echo _
"----------------------------------------------------< SECURITYCENTER >-------------------------------------------------" & vbNewLine & _
"<SCV> : " & scSCV & "" & vbNewLine & _
"<CATEGORY> : " & scCat & "" & vbNewLine & _
"<COMPANY> : " & scComp & "" & vbNewLine & _
"<PRODUCT> : " & scProd & "" & vbNewLine & _
"<VERSION> : " & scVer & "" & vbNewLine & _
"<ENABLED> : " & scEna & "" & vbNewLine & _
"<UPTODATE> : " & scDate & "" & vbNewLine & _
"----------------------------------------------------<##################>-------------------------------------------------" & vbNewLine
End Sub
Sub writeXMLDISK(FreeSpaceDisk,SizeDisk,NameDisk)
Wscript.Echo _
"----------------------------------------------------< Espace_Disque >-------------------------------------------------" & vbNewLine & _
"<NAMEDISK> : " & NameDisk & "" & vbNewLine & _
"<DESCRIPTION> : " & Description & "" & vbNewLine & _
"<FREESPACE> : " & FreeSpaceDisk & "" & vbNewLine & _
"<SIZE> : " & SizeDisk & "" & vbNewLine & _
"----------------------------------------------------<##################>-------------------------------------------------" & vbNewLine
End Sub
Sub writeXMLTIME(dtmDate1,POS)
Wscript.Echo _
"----------------------------------------------------< DATE & HEURE >----------------------------------------------------" & vbNewLine & _
"- -" & vbNewLine & _
"- Debut_d_execution_du_script " & POS & " : " & dtmDate1 & " " & POS & " -" & vbNewLine & _
"- -" & vbNewLine & _
"----------------------------------------------------<##################>----------------------------------------------------" & vbNewLine
End Sub
Sub writeXMLTIMEDIFF(DTMstart,DTMstop)
Wscript.Echo _
"-----------------------------------------------------< Duree du script >-------------------------------------------------" & vbNewLine & _
"- Temps_d_execution_du_script : " & DateDiff("s",DTMstart,DTMstop) & " secondes -" & vbNewLine & _
"-----------------------------------------------------<#################>-------------------------------------------------" & vbNewLine
End Sub
Sub writeXMLSizeTempIE (TempIE)
WScript.Echo _
"-----------------------------------------------------< Temporaire IE >-------------------------------------------------" & vbNewLine & _
"- Taille_du_dossier_temporaire_d_'_Internet_Explorer : " & TempIE & " Octets -" & vbNewLine & _
"-----------------------------------------------------<#################>-------------------------------------------------" & vbNewLine
End Sub
Sub writeXMLSizeWinTemp (WinTemp)
WScript.Echo _
"-----------------------------------------------------< Windows Temp >-------------------------------------------------" & vbNewLine & _
"- Taille_du_dossier_Windows_TEMP : " & WinTemp & " Octets -" & vbNewLine & _
"-----------------------------------------------------<#################>-------------------------------------------------" & vbNewLine
End Sub
Function dec2bin (n)
b = Trim((n Mod 2))
n = n \ 2
Do While n <> 0
b = Trim((n Mod 2)) & b
n = n \ 2
Loop
While Len(b) < 24
b = "0" & b
Wend
dec2bin = b
End Function |
Partager