10
 <RegistryKey Id="MyServerRegInstallDir" Root="HKLM" Key="Software\MyApp\Server" Action="create">
     <RegistryValue Name="InstallDir" Type="string" Value="[INSTALLDIR]" />
     <RegistryValue Name="DataDirectory" Type="string" Value="[MYAPPDATADIR]" />
  </RegistryKey>

The subkeys InstallDir and DataDirectory is deleted on uninstall. How do I prevent it?

Ideally Action="create" must do it.

Rohit
  • 3,610
  • 7
  • 45
  • 76
  • What is the purpose of leaving data in the registry after the program is removed? – apaderno Jun 27 '10 at 01:51
  • 1
    When the application is installed again it can recover. – Rohit Jun 27 '10 at 02:06
  • 2
    I've given you a pointer to something that might work below. But I agree with kiamlaluno, your uninstaller should do its best to putting the machine in a clean state when it uninstalls. Because if your settings are corrupt and causes the app to get into a bad state, the classic "uninstall then reinstall" solution won't work. – selbie Jun 27 '10 at 02:12

1 Answers1

23

Set the Permanent="yes" attribute on the parent component.

http://wix.sourceforge.net/manual-wix3/wix_xsd_component.htm

Permanent YesNoType

If this attribute is set to 'yes', the installer does not remove the component during an uninstall. The installer registers an extra system client for the component in the Windows Installer registry settings (which basically just means that at least one product is always referencing this component). Note that this option differs from the behavior of not setting a guid because although the component is permanent, it is still patchable (because Windows Installer still tracks it), it's just not uninstallable.

selbie
  • 100,020
  • 15
  • 103
  • 173