Saturday, March 8, 2008

Script to check MSI Products installed on a PC

The following code example shows how to generate an inventory list of installed software on a local computer. Please bear in mind this script does not return all software installed on a PC, it ONLY returns the one that were installed using MSI.

'Set computer name - replace variable with appropriate value

Computer = "."


'Obtain collection of Windows Installer packages

Set MSIapps = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer &_ "\root\cimv2").ExecQuery("select * from Win32_Product")


'Obtain number of program in collection

AppList = AppList & MSIapps.Count & " MSI packages installed:" & VBCRLF & "------" & VBCRLF


'Enumerate the names of the packages in the collection

For each App in MSIapps

AppList = AppList & App.Name & VBCRLF

Next

'Display list of MSI packages

Wscript.Echo AppList

No comments: