Question

I'm using a WiX installer file to edit a registry entry however when it's uninstalled I want it to be set do a default value of 0.

Here is the code I'm using to set it to 1.

  <DirectoryRef Id="TARGETDIR">
<Component Id="RegistryEntries" Guid="PUT-GUID-HERE">
  <RegistryKey Root="HKCU"
               Key="Software\Microsoft\Windows\CurrentVersion\Policies\System"
        Action="createAndRemoveOnUninstall">
    <RegistryValue Type="integer" Name="DisableTaskMgr" Value="1" KeyPath="yes"/>
  </RegistryKey>
</Component>

I want it so that when it uninstalls that it does not delete the key but just sets it to 0 as I am unsure what the behaviour of the taskmanager would be if the key was deleted.

I'm also assuming Action="createAndRemoveOnUninstall" should be something else?

Was it helpful?

Solution

"Action" has been deprecated and instead you should be using "ForceCreateOnInstall" and/or "ForceDeleteOnUninstall" instead.

You can also use "NeverOverwrite" on the component to make sure that the registry value isn't removed.

To set the value you can use a custom action that is scheduled to run only during the uninstall. Use NOT UPGRADINGPRODUCTCODE as the conditional for your custom action to ensure it only executes during uninstall.

For the custom action under Product AND Package add

<InstallExecuteSequence>
  <Custom Action="YourCustomAction" After="InstallInitialize"><![CDATA[(NOT UPGRADINGPRODUCTCODE)]]></Custom>
</InstallExecuteSequence>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top