Using WiX to create registry values

A common installation requirement is to set registry variables. WiX makes this a simple task. Lets add a RegistryKey element and nested RegistryValue element.

The RegistryKey element defines the specific key that should be created. The Action attribute is an enumeration. The allowable values are specified below:

  • create
  • createKeyAndRemoveKeyOnUninstall
  • none

RegistryKey creates a key if it does not exist or edits it if it already does.

The root attribute is an enumeration for the registry root. Allowable values are:

  • HKMU
  • HKCR
  • HKCU
  • HKLM
  • HKU

The RegistryValue represents the data that is to be written to the parent RegistryKey. The Type attribute defines the registry data type while the Value attribute stores the actual data. The Name attribute stores the name of the value.

There are also RemoveRegistryValue and RemoveRegistryKey elements that can be used to remove keys and values in the same manner that they are added.

To conclude WiX provides tools for adding/removing and editing registry values and resetting those values during uninstall.