Question

Imagine you have a variable called programVersion. We use this variable to publish on registry the version of our application in HKLM.

We have some conditions to check if a specific version OF ANOTHER PROGRAM is installed on our machine checking this registry values:

<Property Id="ANOTHER_APP_INSTALLED">
  <RegistrySearch Id="AnotherAppInstalled" Root="HKLM"
                    Key="$(var.keyPathProgram)$(var.AnotherProgramVersion)"
                    Name="Path"
                    Type="raw" />
</Property>

But now I created a new version of the OTHER program, and I want to check if the older version or this newer exist on my registry on my NEW application. So I need to check both versions like this:

<Property Id="ANOTHER_APP_INSTALLED">
  <RegistrySearch Id="AnotherAppInstalled" Root="HKLM"
                    Key="$(var.keyPathProgram)$(var.AnotherProgramVersion)"
                    Name="Path"
                    Type="raw" />
</Property>
<Property Id="ANOTHER_APPV11_INSTALLED">
  <RegistrySearch Id="AnotherAppV11Installed" Root="HKLM"
                    Key="$(var.keyPathProgram)$(var.AnotherProgramVersion11)"
                    Name="Path"
                    Type="raw" />
</Property>

Is there any way to put an asterisk after a variable, that accepts any value after it? Something like this:

<Property Id="ANOTHER_APP_INSTALLED">
  <RegistrySearch Id="AnotherAppInstalled" Root="HKLM"
                    Key="$(var.keyPathProgram)$(var.AnotherProgramVersion)*"
                    Name="Path"
                    Type="raw" />
</Property>

Here's the way I check if any of them is installed:

<![CDATA[ ANOTHER_APP_INSTALLED or ANOTHER_APPV11_INSTALLED ]]>

RECAP:

So I have an installed program on my machine that checks if another application is installed in any version, not my own application. I need it to check if that other application is installed in any of its possible versions.

EDIT: I need to ckeck if v1, v1.1, v1.2, v1.3... is installed. But I need to allow all of them to be a possible installed version, not only one of them. I need to check for every version that exists of the product.

I know this is not the regular behaviour of WiX, but I need it to behave like that.

Was it helpful?

Solution

Update

Generally, applications put the installed version in a key which is common to all of it's versions for example InstalledVersion key. Once you have read the value from this key you can then use it to allow or disallow installation of your application using WIX conditions.

<Condition Message="This setup requires OTHER software version 1 or higher.">
  <![CDATA[OtherSoftwareVersionProperty >= "1"]]>
</Condition>

The above condition will allow your software to be installed for ANY version of OTHER software which is greater than 1.

or use this to allow installation only when specific versions are found:

<Condition Message="This setup requires OTHER software version 1.1.1 or 1.1.2.">
  <![CDATA[OtherSoftwareVersionProperty = "1.1.1" OR OtherSoftwareVersionProperty = "1.1.2"]]>
</Condition>

But if your OTHER software creates separate keys for all it's versions then you will have to use a separate registry search for each one of them and then use them in a single condition as explained above.


Following answer does not make much sense after the OP updated the question

If all you want to do is check for versions of your program and prevent or allow upgrades and downgrades then I think you should look at the MajorUpgrade element. There is also a good tutorial on How To: Implement a Major Upgrade In Your Installer.

If you just want to prevent upgrades and downgrades then you can use

<MajorUpgrade AllowDowngrades="no" DowngradeErrorMessage="A newer version of [ProductName] is already installed." Disallow="yes" DisallowUpgradeErrorMessage="Please remove previous version of [ProductName]." />

Make sure you add an UpgradeCode attribute to your Product element.

OTHER TIPS

If any Registry search is fine then why not search till little upper level like

Something like

<RegistrySearch Id="AnotherAppV11Installed" Root="HKLM"
                    Key="$(var.keyPathProgram)"
                    Name="Path"
                    Type="raw" />

Or You can also use FileSearch element to Detect Certain File version of your Another program and in Blocker Use like

<![CDATA[ ANOTHER_APP_INSTALLED <10.0     ]]>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top