Phil
Phil

Reputation: 3994

Wix installer finding registry key that does not exist

I'm creating an installer for one of our products. The installer was done with WISE earlier but we wanted to change this to wix with this release. It's important that our users uninstall the old version of the product before installing the new version and thus I need to check for a key in the registry that was created by the old installer (the key is removed when the old version is uninstalled).

I have a conditional check in the wxs like so:

<!-- Check if older version of Product has been installed. Must be removed by user-->
<!-- The key below is set by the old installer. If it exists, the old version is there.-->
<Property Id="OLDKEY">
  <RegistrySearch Id="OldRegKey" Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Company Product för Product" Name="DisplayName" Type="raw"></RegistrySearch>
</Property>

<Condition Message="You need to uninstall the old version of Product before installing this one.">
  OLDKEY
</Condition>

You'll notice a Swedish character in there. I suspect this might be the cause of some problems. This is how I configured since I had to handle Swedish characters:

<Product
  Id="*"
  Name="$(var.Manufacturer) $(var.ApplicationName)"
  Language="1033"
  Version="!(bind.FileVersion.Product.exe)"
  Manufacturer="$(var.Manufacturer) AB"
  UpgradeCode="[GUID]"
  Codepage="1252"
>

Notice the 1252 codepage.

When I install and have the old version on the machine, I find the key in the registry and the installer will show me the message. If I remove the old version I can see the registry key disappear but the installer will still show me the message and exit. I have tried rebooting (you never know) to no avail.

I'm running out of ideas... any thoughts?

Upvotes: 1

Views: 2576

Answers (1)

Phil
Phil

Reputation: 3994

Turns out the registry search returns 1 if key is not found. So I changed

OLDKEY

To

<![CDATA[OLDKEY <> 1]]>

And it was fixed.

Upvotes: 2

Related Questions