I'm trying to write a registry value to HMLM using WIX installer, but no luck so far.
I have read official documentation, and some related information. Pitty, but official doc only says how to write to HKLU, that does not suit my needs.
I have also looked at some questions like Cannot create registry key value with WiX installer but if I try doing like this and put it in
I have x86 installer and also tried to follow recomendation for writing to Software\Wow6432Node, but no luck.
May be there is some difference in setting it in 3.10 version? Can someone write example including some surroundings to figure out how and where shoud the value be put to create a registry folder + key-values on install and delete them on uninstall?
Thank you very much.
To write to the registry you need to add the <RegistryValue> element as a child to a <Component>.
In the short snippet I created a component which will add a registry entry to the registry at HKLM\SOFTWARE\$(var.RegistryRootKeyName)\v7 called "ClientPath" with the value of the INSTALLDIR property.
<DirectoryRef Id="BIN">
<Component Id="program.exe">
<File Id="program.exe" KeyPath="yes" Source="$(var.BinariesDir)\_bin\program.exe" />
<Shortcut
Id="ClientInstallDirShortcut"
Name="$(var.Product) $(var.InstallerVersion)"
Directory="INSTALLDIR"
Target="[#program.exe]"
WorkingDirectory="BIN"/>
<RegistryValue
Id="ClientInstallDirRegShortcut"
Root="HKLM"
Key="SOFTWARE\$(var.RegistryRootKeyName)\v7"
Type="string"
Name="ClientPath"
Value="[INSTALLDIR]"/>
</Component>
</DirectoryRef>
Now, to have this registry created, you need to include the Component in a feature that is installed during your install.
<Feature Id="ClientMain" Title="Client" Level="1" >
<ComponentRef Id="program.exe" />
</Feature>
Because you own this registry location, once you uninstall everything related to the component the registry entries will be automatically removed by the windows installer and the folders created as well if they are empty.
I think the issue you are having is related to the confusion around HKLM\SOFTWARE\Wow6432Node. You don't actually have to specify Wow6432Node in your registry key. If you do, then your registry key is probably going to HKLM\SOFTWARE\Wow6432Node\Wow6432Node\...
There are two 'views' of the registry you can see when you open/create a registry key on a 64 bit machine. You can use the 32-bit view or the 64-bit view.
When you are using the 32 bit view, Wow6432Node is automatically inserted into your registry key path for HKLM\SOFTWARE\... . You can force the 64 bit view by adding Win64="yes" to your registryvalue element but you should make sure you are only trying to write to or read the 64 bit registry on a 64 bit machine.
The default view the registry uses is tied to the bitness of the process. If you are running a 64-bit process installer on a 64-bit machine, to access the 32-bit registry locations you need to set Win64="no" (I think this is how it works). Similarily for a 32-bit installer, the default view is the 32-bit registry which automatically adds Wow6432Node to your HKLM\SOFTWARE registry keys.