Find the Product

Find the Product

  • Comments 4

The Windows SDK Team instructs users how to uninstall older Platform SDK installations without the original source installation media. As part of their instructions, they write,

RemoveProgram Files\Microsoft SDK folder
This is the painful part:
Find all .msi that are releated to the February 2003 release in
from the cmd line you can run msiexec.exe -x nameofmsi.msi

There are a few ways of doing this. You could navigate to %WINDIR%\Installer in Windows Explorer - a hidden folder for good reason - and add both the Title and Comments columns to the detail view (since some package misuse the Title Summary Property for a description of what their package installs). You could then scan the descriptions to find the right package.

Take note, however, that %WINDIR%\Installer is a hidden folder because it is not meant for general access, and is maintained by Windows Installer and could change without warning since it is not officially documented. In general you should not be in this folder, and even if you're simply curious be very careful about what you do.

The Windows Installer programming interfaces provide you with everything you need to access the product. If you know the ProductCode you could call the MsiOpenProduct function to get a handle to the product, then call the MsiGetActiveDatabase function to get a handle to the database without knowing the path, and from that query tables or do anything else. Using these functions, patches are even brought into view unless you call the MsiOpenPackageEx function with dwOptions set to include MSIOPENPACKAGEFLAGS_IGNOREMACHINESTATE (1).

You can also pass the ProductCode to "msiexec -x {ProductCode}" instead of using the package path.

Without accessing the %WINDIR%\Installer directory then, or assuming that some package comments are not easily identifiable, how can you find the ProductCode or even the locally cached product package? You can use the MsiEnumProducts function, and for each result call the MsiGetProductInfo function to fetch common properties like the ProductCode, ProductName, ProductVersion, and more - even the local cache location if you just want to, for example, view the .msi file in Orca.

I have posted a simple example showing how to do this, as well as the binary since this could be a useful tool for those not interested in the source. This sample is not supported by Microsoft so use it at your own risk, but feel free to post comments or questions here.

Leave a Comment
  • Please add 4 and 6 and type the answer here:
  • Post
  • The program doesn't need to be an exe - script can do this stuff easily for admins that might want to do something similar without using Visual Studio (beware line breaks):
    Option Explicit
    Public installer, fullmsg, comp, prod, a, fso, pname, ploc, pid,contxt, sid, psorce, pcache

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set a = fso.CreateTextFile("prodex.txt", True)

    ' Connect to Windows Installer object
    Set installer = CreateObject("WindowsInstaller.Installer")
    a.writeline ("Products")
    'on error resume next
    For Each prod In installer.ProductsEx("", "", 7)
      pid = prod.ProductCode
      contxt = prod.Context
      pname = prod.InstallProperty("InstalledProductName")
      psorce=prod.InstallProperty( "InstallSource")
      ploc =prod.InstallProperty( "InstallLocation")  
    pcache = prod.InstallProperty("LocalPackage")
      a.writeline (pid & " " & pname & " installed at <" & ploc & "> from " & psorce & " Context " & contxt & " Cached at " &  pcache)
  • Thanks Phil. I realize it doesn't need to be an EXE, but given almost all my samples thus far have been Script and Script is well into sustained engineering I felt like transitioning away from it.

    I'm actually designing some cmdlets for PowerShell ( I still prefer "msh" :( ) so that administrators can work with Windows Installer using the next-generation scripting environment.

    BTW, is this Phil Wilson the author and MVP? If so, could you drop me an email using the contact form?
  • Some time back I mentioned in a comment I was working on some PowerShell extensions for Windows Installer.

  • Any Chance of getting these old links updated as the links seem to be down.

Page 1 of 1 (4 items)