wixwindows-installerregistrywix4heatwave

WiX Toolset Uninstall with RegistrySearch/Condition


I'm trying to uninstall an application via the *.msi file. The *.msi file is generated by my WixToolset-Project.

My problem is that the uninstall process is failing because of the RegistrySearch Element and the Launch Element. The Launch-Condition will be evaluated as true and interrupts the uninstall process. The Launch Condition itself checks if the required key is installed. The required key is installed. Otherwise it wouldn't be possible to install the application. From the logs I can see that the key was read by the RegistrySearch Element correctly.

My code so far:

Package.wxs with Launch and RegistrySearch Condition

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
     xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
  <Package Name="RegistryKeyWix" Manufacturer="TODO Manufacturer" Version="1.0.0.0" UpgradeCode="[GUID]">
    <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />

      <Property Id="REGISTRYKEYPROP" >
          <RegistrySearch Id="RegistryKeySearch" Key="SOFTWARE\Test\Testkey" Name="pc" Type="raw" Root="HKLM" Bitness="always64"/>
      </Property>

      <Launch Condition="REGISTRYKEYPROP&lt;&gt;&quot;&quot;" Message="Required key not installed"/>
      
    <Feature Id="Main">
      <ComponentGroupRef Id="ExampleComponents" />
    </Feature>

      <ui:WixUI Id="WixUI_Minimal"/>
  </Package>
</Wix>  

ExampleComponents from the WiX template

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
    <Fragment>
        <ComponentGroup Id="ExampleComponents" Directory="INSTALLFOLDER">
            <Component>
                <File Source="ExampleComponents.wxs" />
            </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

Folder.wxs generated by the WiX template

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <Fragment>
    <StandardDirectory Id="ProgramFiles6432Folder">
      <Directory Id="INSTALLFOLDER" Name="!(bind.Property.Manufacturer) !(bind.Property.ProductName)" />
    </StandardDirectory>
  </Fragment>
</Wix>

And the *.reg file for key installation:


[HKEY_LOCAL_MACHINE\SOFTWARE\Test\Testkey]
"pc"="571E721F-2F6C-4604-9898-1FD2B5FE9BF6"

My expectation is a trouble-free uninstall process and I have no idea why it's not working.


Solution

  • Generally, we never want launch conditions to interfere with a repair, change or uninstall. To achieve this we add or Installed to all of our conditions so that they will always evaluate to true.

    Case in point... a prereq on .NET Framework or similiar. We want it to block installation but if someone removes it we don't want it to block application removal.