Search code examples
wixcustom-actionregistrykey

How to modify the registry key value on uninstall without removing the key from registry in wix?


I added a registry key value into the registry on install.And I want to modify that registry key value on uninstall but I don't want to removing that from registry.

1)I tried with custom actions execution on uninstall to modify the registry value. But the registry values are removing from the registry on uninstall.

2)If I make the component to permenent then it is not modifying the key value at the time of uninstall.

  <Component Id="SampleRegComp"
       Guid="3865FE52-F8EE-4E29-B321-BDF0FD6D3F58"
             Permanent="yes">
    <RegistryKey Action="create"
      Key="SOFTWARE\Microsoft\Notepad"
      Root="HKCU">
      <RegistryValue Name="StatusBar" Type="integer" Value="1" />
    </RegistryKey>

  </Component>

<CustomAction
Id="ModifyOutlookRegInitSign_12"
Return="ignore"
Directory="TARGETDIR"
ExeCommand= "&quot;[SystemFolder]reg.exe&quot; ADD &quot;HKCU\SOFTWARE\Microsoft\Notepad&quot; /v StatusBar /t integer /d 0 /f" >
</CustomAction>

Installed


Solution

  • The short answer is to create the registry entry with your code and modify it with your code, then it's clear that you are managing those entries, not both you and the MSI setup.

    An alternative is to put them in a component by itself with a null component guid, then MSI won't manage it at all after it's been installed.