How to check an installed version of a product from MSI

15,191

Solution 1

To do it properly, you probably want to use a custom action. Inside the custom action, use the MsiGetProductInfo function.

A way of doing it in pure-WiX would be to modify the example found here: How do I compare registry versions in WiX?

First create a RegistrySearch element:

<Property Id="PRODUCTVERSION">
    <RegistrySearch Id="ProductVersionSearch" Root="HKLM" Key="software\Microsoft\Windows\Current Version\Uninstall\[PRODUCTCODE]" Name="DisplayVersion" Type="raw" />
</Property>

Then use a Condition element:

<Condition Message="Product version 1.10.0 must be installed">
    <![CDATA[PRODUCTVERSION AND PRODUCTVERSION = "1.10.0"]]>
</Condition>

This would search for exactly version 1.10.0, so may not be what you want if you're looking for something like "v1.10.0 or newer"... But should get you started.

Solution 2

Perhaps try the proposed solution in this post: WiX Installer: getting version of the product being upgraded

It involves using the Upgrade table to identify the installed product, and a custom action using VBScript to determine the version.

Solution 3

If you want to do something like create an error message or fail the install if that version is present you can have multiple upgrade entries. Have one that has something like this, bad syntax...

<Property Id="VERSION110INSTALLED" Secure="yes" />
<Upgrade Id="YOUR_GUID">
  <UpgradeVersion
   Minimum="1.10.0" Maximum="1.10.0"
   Property="VERSION110SINSTALLED"
   IncludeMinimum="yes" IncludeMaximum="yes" OnlyDetect="yes" />
</Upgrade>

Then you have that property set if version 1.10.0 is present, and if you want to produce an error message condition it on VERSION110SINSTALLED, and sequence it after FindRelatedProducts.

Share:
15,191
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    After review a lot of posts in this site finally I decide to put mine. I am preparing an MSI file with Wix. I need to check if a particular version of an enterprise product is installed, before to install my system. I have the GUID of that product (which is the same for all versions), but I need to check if 1.10.0 version is installed. Any idea, please. Thanks in advance.

    PD: I am newbie in Wix, so at this moment I am just using the wxs file created by default with the Setup Project.

    Clarifying: I don't want to upgrade the software that I am installing, I need to check another program and version which my installer depends.