Script per salvare in file xls la lista dei software installati

Utilizzando questo script come script di logon, verrrà creato un file xls NOMEUTENTE_NOMEPC con tutti i software installati nella macchina locale. Vi potrà essere molto utile per fare un censimento del SW utilizzato sui client della vostra LAN.

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")
dim nomeUtente
For Each objSoftware in colSoftware
nomeUtente = objSoftware.UserName
nomeMacchina = objSoftware.Caption
next
dim dominio
dim shareFOlder
'******Init Config****************
dominio = "NOME_DOMINIO"
shareFolder = "\\NOME_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
Set objTextFile = objFSO.CreateTextFile(pathfile, True)
objTextFile.WriteLine nomeMacchina & vbtab & nomeUtente & vbCrLf
Set colSoftware = objWMIService.ExecQuery("Select Caption,Vendor,Version from Win32_Product")
objTextFile.WriteLine "Caption" & vbtab & "Vendor" & vbtab & "Version"
For Each objSoftware in colSoftware
objTextFile.WriteLine objSoftware.Caption & vbtab & _
objSoftware.Vendor & vbtab & _
objSoftware.Version
Next
objTextFile.Close
End If
set fso = Nothing
End If

Nessun commento: