How to install different registry entries based on the Operating System (32/64-bit)?

When distributing a mixed 32/64-bit package, the application installed by the package may use a 32-bit or 64-bit version of the same registry key. In this How-To, the package must create a 32-bit version or a 64-bit version of the HKEY_LOCAL_MACHINE\Software\MyKey registry key.

The tree control in the Registry page does not support duplicate entries, but the "Registry" table inside the MSI supports them. Therefore, a solution is to create a key which uses a property in its name. Here are the steps for the HKEY_LOCAL_MACHINE\Software\MyKey registry key (you can adapt the example to your custom registry keys):

- Go to the "Registry" page and create the HKEY_LOCAL_MACHINE\Software\MyKey registry key

- Add your 32-bit registry values in it

Registry Value

- Go to the Organization page and select the feature which contains the registry values

- Press SHIFT+F4 on your keyboard to see the contents of the feature

- Select the components of the 32-bit registry values, right-click one of them and select the "Properties" menu

- In the "Edit Component Properties" dialog set the Condition field to NOT VersionNT64

Edit Component Properties

- Go to the Properties page and create a custom property (for example MY_REG_KEY)

- Set its value to the name of your custom registry key (MyKey)

New Property

- Go to the "Registry" page and select the parent key of your custom registry key (HKEY_LOCAL_MACHINE\Software)

- Create under it a new registry key

- Rename it to the custom property you created ([MY_REG_KEY])

Now you should have these keys: HKEY_LOCAL_MACHINE\Software\MyKey and HKEY_LOCAL_MACHINE\Software\[MY_REG_KEY]

Registry Hive

Add the 64-bit registry values in the [MY_REG_KEY] key

Go to the "Organization" page and select the feature which contains them

Press SHIFT+F4 on your keyboard and select the components of the 64-bit registry values

Right-click one of them and select the "Properties" menu

In the "Edit Component Properties" dialog set the Condition field to VersionNT64

Tick the option 64-bit Component

Edit Component Properties

If the 32-bit values are in the same feature as the 64-bit values, the components of the values with the same name will be different. For example, if you add the "MyValue" registry value in one key and then add it in another key, the components will be named:

  • MyValue for the first key
  • MyValue_1 for the second key

Organization Page

If you use this approach, the package will determine the type of the target system (32/64-bit) by using the "VersionNT64" property. Also, it will install only the components which correspond to the system type.