title: Writing install location to registry from installer
body: <p>I am using <a href="http://wix.codeplex.com/releases/view/75656" rel="nofollow">WiX 3.6</a> to create an installer.</p>
  
  <p>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.</p>
  
  <p>Now based on the research I have done I think the following should work</p>
  
  <pre><code>&lt;RegistryKey Root="HKMU" 
               Key="Software\OpenCover" 
               Action="createAndRemoveOnUninstall"&gt;
    &lt;RegistryValue  Name="Location" 
                    Type="string" 
                    Value="[APPLICATIONFOLDER]" 
                    Action="write" 
                    KeyPath="yes" /&gt;
  &lt;/RegistryKey&gt;
  </code></pre>
  
  <p><strong>The problem is it only works for when ALLUSERS="" i.e. HKMU is interpreted as HKCU.</strong> </p>
  
  <p>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.</p>
  
  <pre><code>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: 
  </code></pre>
  
  <p>Can someone explain how to achieve the task I need to complete</p>