1

I need help in connecting 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

ravikanth
  • 24,922
  • 4
  • 60
  • 60
Namshith Hash
  • 11
  • 1
  • 2

2 Answers2

3

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!

ravikanth
  • 24,922
  • 4
  • 60
  • 60
1

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.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • Hi,Thanks for the response. I get an error 'Path Not Found' when I execute the script. (I have specified the computer name in the strComputer) – Namshith Hash Apr 07 '11 at 14:13
  • if you see the second line of the sample code, this create a file called `software.tsv` in the `C:\scripts` folder, this folder must exist. anyway you can use the tools which I recommended you to see another examples to how access this wmi class. – RRUZ Apr 07 '11 at 14:40