Ottenere le informazioni di un PC

Con questo script potrete ottenere alcune informazioni (CPU, Hard Disk, Processore) di un PC.

Set objFSO = CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery ("Select UserName,Caption from Win32_ComputerSystem")
For Each objSoftware in colSoftware
nomeUtente = objSoftware.UserName
nomeMacchina = objSoftware.Caption
next
dim dominio
dim shareFOlder
'******Init Config****************
dominio = "NOME-DOMINIO"
shareFolder = "\\MIO_PC\PUBLIC SHARE\"
'******End Config********************
if not IsNull(nomeUtente) then
nomeUtente = replace(nomeUtente,dominio & "\","")
dim pathFile
pathFile = shareFolder & nomeUtente & nomeMacchina & ".xls"
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If not fso.FileExists(pathFile) Then
'processor informations
Set colSoftware = objWMIService.ExecQuery("Select Manufacturer,Name from Win32_processor")
For Each objSoftware in colSoftware
procManuf = objSoftware.Manufacturer
procName = objSoftware.Name
Next
'Computer Informations
Set colSoftware = objWMIService.ExecQuery("Select Model,Manufacturer from Win32_ComputerSystem")
For Each objSoftware in colSoftware
pcModel = objSoftware.Model
pcManuf = objSoftware.Manufacturer
Next
'HDD Informations
Set colSoftware = objWMIService.ExecQuery("Select Size from Win32_LogicalDisk where caption = 'C:'")
For Each objSoftware in colSoftware
hddSize = objSoftware.Size
'hddVolName = objSoftware.VolumeName
Next
'scrivo il file
Set objTextFile = objFSO.CreateTextFile(pathfile, True)
objTextFile.WriteLine nomeMacchina & vbtab & nomeUtente & vbCrLf
'preparo intestazione file
objTextFile.WriteLine "Processore" & vbtab & "Nome Processore" & vbtab & "Modello PC" & vbtab & "Manufacturer" & vbtab & "HDD Size" & vbCrLf
objTextFile.WriteLine procManuf & vbtab & procName & vbtab & pcModel & vbtab & pcManuf & vbtab & hddSize
objTextFile.Close
End If
set fso = Nothing
end if

Nessun commento: