I need help in conne开发者_如何学Ccting to 2 remote machines running Windows XP and retrive details of a software version and installation date. I am new to WMI and would appreciate if someone could guide me in the right direction.
At the moment , I execute the below command manually on the machines. wmic product where "Vendor like '%xyz%'" get Name, Version
I will give you a much simple version written in PowerShell.
Get-WmiObject -Class Win32_Product | Select Version,InstallDate | Export-Csv -Path C:\Scripts\Software.csv
Simple!
in order to list the installed software in a local or remote machine using the WMI you must use the Win32_Product
wmi class.
check this vbscript sample
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("c:\scripts\software.tsv", True)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("SELECT * FROM Win32_Product")
objTextFile.WriteLine "Caption" & vbtab & _
"Description" & vbtab & "Identifying Number" & vbtab & _
"Install Date" & vbtab & "Install Location" & vbtab & _
"Install State" & vbtab & "Name" & vbtab & _
"Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _
& "Version"
For Each objSoftware in colSoftware
objTextFile.WriteLine objSoftware.Caption & vbtab & _
objSoftware.Description & vbtab & _
objSoftware.IdentifyingNumber & vbtab & _
objSoftware.InstallLocation & vbtab & _
objSoftware.InstallState & vbtab & _
objSoftware.Name & vbtab & _
objSoftware.PackageCache & vbtab & _
objSoftware.SKUNumber & vbtab & _
objSoftware.Vendor & vbtab & _
objSoftware.Version
Next
objTextFile.Close
if you need use this wmi class from another language like C#, Vb Net or Delphi you can use a tool like the WMI Code Creator
or WMI Delphi Code Creator
to help you to build the WQL sentence.
精彩评论