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

StackOverflow https://stackoverflow.com/questions/22660282

  •  21-06-2023
  •  | 
  •  

Question

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

Était-ce utile?

La 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.

Autres conseils

Phil has already answered, but maybe I can add that you can use (REMOVE="ALL" AND NOT UPGRADINGPRODUCTCODE) for the custom action to be executed during uninstallation. Then just set the registry component permanent (HKCU registry data shouldn't really be uninstalled either - a matter of some debate though). This still won't fix the HKCU data for users who are not logged on at the time of the uninstall though. This is a much more involved task, probably possible to do with ActiveSetup.

Adding NOT UPGRADINGPRODUCTCODE ensures uninstalls performed as part of major upgrades do not update the registry since the product is then due to be reinstalled. Shouldn't be necessary for your case, but ensures the custom action doesn't run unnecessarily.

I would suggest scheduling the custom action right before InstallFinalize in the InstallExecuteSequence. I haven't tested this location, but it is then one of the last actions to run during the uninstall, and should have the desired effect.

See the condition lists for detecting different installation modes at the bottom of this thread.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top