I am using WiX 3.6 to create an installer.

One of the needs is to write the location of the install location to the registry in either HKCU or HKLM depending on the ALLUSERS property.

Now based on the research I have done I think the following should work

<RegistryKey Root="HKMU" 
             Key="Software\OpenCover" 
             Action="createAndRemoveOnUninstall">
  <RegistryValue  Name="Location" 
                  Type="string" 
                  Value="[APPLICATIONFOLDER]" 
                  Action="write" 
                  KeyPath="yes" />
</RegistryKey>

The problem is it only works for when ALLUSERS="" i.e. HKMU is interpreted as HKCU.

If I try a perMachine installation where ALLUSERS=1 then the entry is not written to HKLM as expected, though when I look at the installer log file I see the call to WriteRegistryValues.

MSI (s) (D4:14) [22:46:24:901]: Executing op: ActionStart(Name=WriteRegistryValues,Description=Writing system registry values,Template=Key: [1], Name: [2], Value: [3])
Action 22:46:24: WriteRegistryValues. Writing system registry values
MSI (s) (D4:14) [22:46:24:902]: Executing op: ProgressTotal(Total=2,Type=1,ByteEquivalent=13200)
MSI (s) (D4:14) [22:46:24:903]: Executing op: RegOpenKey(Root=-1,Key=Software\OpenCover,,BinaryType=0,,)
MSI (s) (D4:14) [22:46:24:903]: Executing op: RegAddValue(Name=ConsoleLocation,Value=C:\Program Files (x86)\OpenCover\,)
WriteRegistryValues: Key: \Software\OpenCover, Name: ConsoleLocation, Value: C:\Program Files (x86)\OpenCover\
MSI (s) (D4:14) [22:46:24:906]: Executing op: RegCreateKey()
WriteRegistryValues: Key: \Software\OpenCover, Name: , Value: 

Can someone explain how to achieve the task I need to complete

有帮助吗?

解决方案

The problem is actually to do with a 32 bit installer on a 64 bit platform.

When ALLUSERS="1" is used in this scenario then the registry entries, marked up with HKMU, are actually being written, but under in this case, HKLM\Software\Wow6432Node\OpenCover. I suspect entries marked as HKLM are also redirected in the same manner.

Unfortunately the documentation on WriteRegistryValues Action does not explain the 32/64 bit of "magic" redirection and the information, details regarding the actual registry entry, doesn't appear in the logs.

To get an insight as to what is happening then the following article demystifies the observed behaviour Registry Keys Affected by WOW64. From this article we can see that the installer "thinks" it is writing to a folder HKLM\Software but this is actually being "redirected" to HKLM\Wow6432Node\Software for a 32 bit process on a 64 bit platform and hence explains why it is not reflected into the log files. The article also explains why when ALLUSERS="" and HKMU is then HKCU why the entries appear where one would expect them to be, because these entries are "shared" between 32 and 64 bit applications.

其他提示

My guess is that your installer isn't elevating (UAC enabled?) and that the write to HKLM is being redirected to HKCU.

BTW, you could also consider using the Windows Installer API from within your application to query the UpgradeCode, ProductCode, ProductInformation(INSTALLLOCATION) without the need to write a registry key to store this metadata.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top