Aaron Stebner's WebLog

Thoughts about setup and deployment issues, WiX, XNA, the .NET Framework and Visual Studio

Using MsiInv to gather information about what is installed on a computer

Using MsiInv to gather information about what is installed on a computer

Rate This
  • Comments 74

As I was reading one of the posts on Quan To's new blog, I noticed that someone posted a link to a tool named msiinv.exe on their tools page.  This tool (which stands for MSI Inventory) wraps some of the publicly documented MSI APIs to provide information about the state of all Windows Installer products, features and components that Windows Installer thinks are installed on your computer.  I say "thinks are installed" because there are some rare cases where the actual installation state of a given product can get out of sync with the information Windows Installer has stored in its internal data structures, which can cause confusion for setup packages.

I use this tool nearly every day as one of the first troubleshooting tools for setup problems because it allows me to get a baseline snapshot of what the current state is for a machine before I start trying to make changes to fix any problems a customer might be having.

Example usage of msiinv.exe

One of the common uses of msiinv.exe is if someone is trying to install one of the recent beta builds of VS 2005 or .NET Framework 2.0 and the setup UI states that you are not allowed to install because a previous beta version of <insert product name here> is on the machine and you must uninstall that first.  Sometimes after receiving this error message, a user will look in Add/Remove Programs and the product that setup is complaining about is nowhere to be found, or there is an Add/Remove Programs entry for that product but trying to remove it claims that the product is not on the computer and asks if you would like to remove the entry from the Add/Remove Programs list.

In these cases, you can use the following steps:

  1. Download msiinv.zip from the following location:

  2. Extract the contents of msiinv.zip to the folder c:\msiinv on your system
  3. Click on the Start menu, choose Run, type cmd and click OK
  4. Type this command:  c:\msiinv\msiinv.exe -p > c:\msiinv\msiinv_output.txt

    Note: This command must be run from a cmd prompt or it will not create a log file as expected.

These steps will create a text file named c:\msiinv\msiinv_output.txt with a list of each product that Windows Installer thinks is installed on the system.  Then you can open the text file in any text editor and search the list of products for the name of the product that setup told you to uninstall.  The output will look something like this (I am using an example from a machine that has .NET Framework 2.0 beta 2 installed):

Microsoft .NET Framework 2.0 Beta 2
 Product code: {7A1ADD0C-17F3-47B8-B033-A06E189C835D}
 Product state: (5) Installed.
 Package code: {856D48D2-6F94-466D-9732-534DB5854FB3}
 Version: 2.0.50215
<note: there is more info after this but I am omitting it because it isn't useful to the rest of my example>

Now we have the Windows Installer product code and we can use that to uninstall the product by running msiexec /x <product code> (make sure that you include the curly braces in this command line).  If the product is actually installed on your system you will see a progress screen and uninstall will complete, and from there you should be able to re-run VS or .NET Framework setup and successfully install.

If Windows Installer thinks that the product is installed but it really isn't, then running msiexec /x <product code> will give you an error stating that this command is only valid for installed products.  If this happens, you will need to perform an extra step to remove the data that causes Windows Installer to think this product is installed.  You can download the Windows Installer Cleanup Utility and install and run it on your machine to fix this.  In the list of applications that this tool displays, choose the one that matches the product name displayed when you first ran VS or .NET Framework setup and choose to remove it.  After this removal completes, you should be able to re-run VS or .NET Framework setup and successfully install.

Advanced usage of msiinv.exe

The msiinv.exe tool has several command line parameters that you can see by running it with the /? switch.  A couple of the more interesting options are the following:

  • msiinv.exe -v - This option will list all feature GUIDs and component GUIDs for each Windows Installer product that is installed on the machine.  This can be useful to see which products share components (which can help track down why running uninstall for one product leaves behind some files and/or registry).  If you have a lot of products installed on the machine, running with the verbose switch will take a long time.
  • msiinv.exe -x - This option will list Windows Installer components that are installed on the machine that do not have any products that hold reference counts on them anymore.  In most cases, this is caused by one or more setup being installed on the machine at some point in the past that violated the MSI component rules. (more info about component rules can be found here and here if you are interested)

<update date="12/1/2008"> Updated the link to msiinv.zip because the old location was no longer available. </update>

<update date="2/12/2009"> Updated command line for running msiinv.exe so it will work on Windows Vista and Windows Server 2008. </update>

<update date="4/1/2009"> Removed broken link to msiinv.exe tool </update>

<update date="10/11/2012"> Embedded new SkyDrive link to msiinv.exe tool </update>


  • Hi Aaron.

    Thanks for your answer.

    For at least one soft (the one I'm concerned with), the orphaned component are not specified as 'Permanent' in the MSI (nor in the ISM as the package has been built with InstallShield 12).

    I'm afraid they remain because of a broken reference counter or something like that due to the way the MSI has been designed (unfortunately). Is there a way to remove them from the system? (without resinstalling the OS)

    I can't find the Component ID in the registry.

  • Hi Boivin - Windows Installer components are stored in an obfuscated manner in the registry, and I wouldn't recommend trying to manually modify any Windows Installer registry data because it is pretty easy to leave your system in an inconsistent state.  These component references aren't going to hurt anything - the worst thing I think could happen here is that if you install some product in the future with that same component in it, it could cause the component reference count to be one too high.  That isn't really going to affect anything, so overall it would probably be best to leave this as is and not try to manually fix it up.

  • Thank you for excellent article!

    It was very-very helpfull for me (I had a big problem with uninstalling Visual Studio 2010 ultimate trial)

  • Tried to upgrade SQL Express 2008 to 2008R2. For some reason the upgrade failed which left my server in a half way installed state. The above procedure helped me to get rid of both 2008 a 2008R2.

  • Hi Aaron, I am using msiinv.exe to monitor a build server farm (ccnet). I get different results when I run under two different domain logins.

    I'm wondering if the API is returning msi entries visible to the user?

    I will try to confirm this - however, would appreciate some guidance from the author.

    thx. Appreciate the excellent tool!

    Andy, NZ

  • Hi Badcop666 at hotmail dot com - I didn't create the MsiInv tool.  I got permission from the person who did to post it and write about it.  I have access to the source code too though, so I took a look and it is just calling standard Windows Installer APIs such as MsiEnumProducts (msdn.microsoft.com/.../aa370101.aspx) to determine what is installed on the computer.  If you have any per-user MSIs or components installed on a computer, then it is definitely possible for you to get different results when running this tool with different domain logins.

  • Thank you *so* much for this. I've manage to uninstall the remnants of a program that's been annoying me for months. It had preventing me from reinstalling the software properly. Fabulous work!

  • Hi Aaron,

    I tried the instructions above at the cmd prompt but I got this message

    "'C:\msiinv\msiinv.exe-p' is not recognized as an internal or external command,operable program or batch file"

    I can run the c:\msiinv\msiinv.exe no problem...I just cannot read that fast! What noob mistake am I making here? Thanks for all your help!

  • Hi keith42 - You need to put a space between msiinv.exe and -p. Can you please give that a try and let me know if it works for you?

  • Hello Aaron,

    I am trying to uninstall the PC Fix Speed and Optimize Your PC which are know to have some malware. I downloaded the file and followed the steps, but these two programs do not show up. I am at a loss. Do you have any suggestions?

  • Hi Shan - The instructions in this blog post only work for applications that use Windows Installer for their setup programs.  If you don't see this application in the list after running msiinv.exe, then it likely doesn't use Windows Installer, and you'll need to use some other means to uninstall it.  There might be an entry in the Programs and Features control panel that you can use to uninstall it, or there might be an uninstaller program in the same directory as the application itself.

  • So somehow my .NET Framework got updated to 4.5.2 during a windows update. While attempting to reinstall Visual Studio 2013 v3, it would simply error out claiming the 4.5.1 .NET Framework could not be installed.

    When checking the log, it gave no indication it's failure was due to a more recent .NET package. Searching a good load of articles on the microsoft website did nothing. Not only that, the FixIt #50123 which is supposed to help fix corrupted MSI packages didn't even mention I was running 3 different versions of .NET framework!

    After tracking down where on the Install CD this package was, I was able to manually run it and see a more detailed error log (I'm sure I could have done this via the VS setup, but it wasn't until reading the comments here that I got the idea). After using the steps you outlined, I quickly found that although the .NET framework wasn't listed in the installed apps, it was on the system, cloaked as a windows KB update.

    After removing it, again using your easy to follow instructions =D, I was able to finally, after two weeks of pain, reinstall my VStudio! I can not thank you enough!

  • The program I'm searching for didn't show up in the output. What do I do?

  • Hi Adrian Arroyo - That means that either the program isn't currently installed on your PC or the program doesn't use Windows Installer for its setup technology.  What is the exact program that you're searching for in your scenario?

Page 5 of 5 (74 items) 12345
Leave a Comment
  • Please add 8 and 8 and type the answer here:
  • Post