views:

85

answers:

1

Hi all,

My WIX-installer shall check for a previously installed version of the software. If there is an older installation it shall be installed in the same path. I'm using RegistrySearch to perform this check.

<Property Id="TARGETDIR">
    <RegistrySearch Id="InstallLocation" Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\[ANYVERSION]" Name="InstallLocation" Type="directory" Win64="no" />
</Property>


where [ANYVERSION] is defined in

<Upgrade Id="MyGUID">
    <UpgradeVersion Property="OLDVERSION" IncludeMinimum="yes" IncludeMaximum="no" Maximum="$(var.VERSION)" Minimum="0.0.0.0" OnlyDetect="no" />
    <UpgradeVersion Property="NEWVERSION" IncludeMinimum="no" Minimum="$(var.VERSION)" Maximum="99.99.99.99" IncludeMaximum="no" OnlyDetect="yes" />
    <UpgradeVersion Property="EQUALVERSION" IncludeMinimum="yes" Minimum="$(var.VERSION)" Maximum="$(var.VERSION)" IncludeMaximum="yes" OnlyDetect="yes" />
    <UpgradeVersion Property="ANYVERSION" IncludeMinimum="yes" Minimum="0.0.0.0" Maximum="99.99.99.99" IncludeMaximum="yes" OnlyDetect="yes" />
</Upgrade>


My check works fine when there is already another version of my software installed.
When there is no earlier installation of my software, the checks works as well with one exception: when there is another application installed which writes an entry (with the name installLocation) without subnode (GUID) in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall the check returns the installLocation of this application.

What is wrong in my check?
Why is RegistrySearch returning the installLocation of the an entry without a subnode?
Is there a possibility to make this work with registrySearch, or do I need to write my own CustomAction?

Many thanks in advance,
Sebastian

A: 

That's because ANYVERSION will be empty if none is found, and the path will then be evaluated to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall.

One solution (not too elegant though) is to capture the registry search in another property, and only set the property that should contain your installation directory (TARGETDIR is probably not the correct choice here either) if ANYVERSION is defined, through a property settings custom action.

On Freund