Welcome to MSDN Blogs Sign in | Join | Help

How do I find all the Windows Installer packages installed on my machine?

Question

How do I find all the Windows Installer packages installed on my machine?

Answer

Here’s the APIs and the Properties one would need

MsiEnumProducts(DWORD,LPTSTR) function [Windows Installer]
MsiEnumProductsEx (8 Parameters) function [Windows Installer]

ProductCode Property

MsiGetProductInfoEx (6 Parameters) function [Windows Installer]
MsiGetProductInfo(LPCTSTR,LPCTSTR,LPTSTR,DWORD) function [Windows Installer]

UpgradeCode property [Windows Installer]

If one were interested in finding the installation location, use

MsiSourceListGetInfo (7 Parameters) function [Windows Installer]
MsiSourceListEnumSources (7 Parameters) function [Windows Installer]
MsiSourceListEnumMediaDisks (10 Parameters) function [Windows Installer]

What would be really cool is to migrate the feature states as well with

MsiQueryFeatureState(LPCTSTR,LPCTSTR) function [Windows Installer]
MsiQueryFeatureStateEx (5 Parameters) function [Windows Installer]

To populate the preselected properties

ADDSOURCE property [Windows Installer]
ADVERTISE property [Windows Installer]
ADDLOCAL property [Windows Installer]
 
[Author: Robert Flaming]
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm.
Published Monday, September 19, 2005 12:00 AM by Windows Installer Team
Filed under: ,

Comments

# re: How do I find all the Windows Installer packages installed on my machine?

Sunday, September 18, 2005 9:50 PM by Paul
I wrote the following VMscript to show all things installed via the installer and product codes and upgrade codes...

'set computer name - replace variable with appropriate value
Computer = "."

Set objWMIService = GetObject("winmgmts:\\" & Computer & "\root\CIMV2")
'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

Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_Property" _
& " WHERE ProductCode = '" _
& App.IdentifyingNumber _
& "' AND Property = 'UpgradeCode'" )

For each objItem in Colitems
upgcode = objItem.Value
exit For
Next

AppList = AppList & App.Name _
& App.IdentifyingNumber & upgcode & VBCRLF
Next

'display list of packages
Wscript.Echo AppList

# re: How do I find all the Windows Installer packages installed on my machine?

Sunday, September 18, 2005 10:04 PM by Windows Installer Team
Thanks Paul. Good Stuff. An example of how there's more than one way to skin the cat with Windows Installer ;^)

[Author: Robert Flaming]
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm.
New Comments to this post are disabled
 
Page view tracker