Search code examples
wixuninstallation

WiX Set Property from Registry during Uninstall


I have the following WiX excerpt which works perfectly during an install but doesn't during uninstall. I'm quite new to WiX so apologies if it's a glaring error. Can anyone see the problem?

<Property Id="APPFOLDER" >

    <RegistrySearch Id="APPInstalledFolderReg"
                    Root="HKLM"
                    Key="SOFTWARE\$(var.MANUFACTURER)\One Of My Web Services"
                    Name="Folder"
                    Type="raw" 
                    Win64="yes" />
</Property>

<CustomAction Id="SetAPPFolderProperty"
              Property="APPInstalledFolder"
              Value="[APPFOLDER]"
              Execute="immediate"
          />

<InstallExecuteSequence>
    <Custom Action="SetAPPFolderProperty"
            After="AppSearch"
            >APPFOLDER</Custom>
    <Custom Action='MyUnregisterAction'
            After='InstallInitialize'
            >REMOVE="ALL"</Custom>
</InstallExecuteSequence>

During "MyUnregisterAction", the APPInstalledFolder is not set. The MsiExec Install Log reports:

Skipping action: SetAPPFolderProperty (condition is false)

I understand this means the CustomAction's not executing because the Property APPFOLDER is not set. Is the RegistrySearch not performed during Uninstall?


Solution

  • The Registry search is definitely performed during an uninstall. As a matter of fact, I tried your snippet and got it to work.

    Are you running the installation in full UI mode? In that case, the registry search will be run in the UI mode. Probably, what is happening here is that , the value of the property APPFOLDER is not passed into the Execute sequence. For the value of the property to be passed to the execute sequence, you need to secure the property ie. add the APPFOLDER property to SecureCustomProperties in the Property table.

    Once you do this, you code snippet should start working.

    In general, under normal circumstances, the values of public properties are passed from the UI sequence to the execute sequence. However, there could be lockdown conditions where the property needs to be explicitly added to the SecureCustomProperties list in the Property table for the value to propogate to the Execute sequence.