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.

Comments (2)

  1. Paul says:

    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 & "rootCIMV2")

    ‘obtain collection of Windows Installer packages

    Set MSIapps = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & Computer &_

    "rootcimv2").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

  2. zhakim says:

    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.