WiX will not add HKLM registry setting during Windows 7 install

20,194

Solution 1

I have figured out why this is happening.

With the WiX installer being compiled on a x86 platform, Windows 7 picked it up as the 32-bit installer with 32-bit registry keys. Windows 7 64-bit handles 32-bit registry entries by doing just what I saw happening.

The program was still registered; it was just not in the 64-bit portion of the registry. Compile it under a x64 platform while making the necessary changes to make it for a 64-bit system (ProgramFileFolder become ProgramFiles64Folder, etc.), and it will put things in the right place.

Solution 2

Thanks for basically solving this one for me!

I just wanted to add that you don't necessarily need to change everything to be x64 for this to work, only the component in question needs to be marked as x64.

<Component Id="MyShellExtension64.dll" Guid="..." Win64="yes">
  <Condition>VersionNT64</Condition>
  <File
    Name="MyShellExtension64.dll"
    Source="MyShellExtension64.dll"
    KeyPath="yes"/>
  <RegistryValue
    Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved"
    Name="{GUID}" Value="My Shell Extension" Type="string"/>
</Component>

Note the Win64="yes", that is all that is required to write to the 64-bit area of the registry. The VersionNT64 condition is there so that this component will only be installed on an x64 system.

In my case this gives ICE80 warnings because I want to install a 64-bit component in the 32-bit ProgramFilesFolder. I'm happy to ignore these because because my main application isn't x64, only the shell extension is, and I don't want to put the shell extension in it's own special folder.

Solution 3

There are some differences to how Windows 7 handles certain registry keys. Registry reflection was removed starting with Windows 7. I am not sure if this plays into what you're seeing here, but check out this link for more on that.

Also, if you're working with a 64-bit version of Windows 7 you might be able to dig down into some specifics by referring to the MSDN 64-bit Windows Programming Guide.

Furthermore, if you need to have different registry keys installed into different locations based on the Windows flavour (XP, Vista, 7, etc.) then this Stack Overflow question also has an answer for you.

Share:
20,194
Scott Boettger
Author by

Scott Boettger

I'm a programmer working my way up. I like C#, WPF, WIX and long walks on the beach. "DWORD to your moms. I came to drop bombs. I got more rhymes than San Jose has dot-coms." - Monzy ftw SOreadytohelp

Updated on February 22, 2020

Comments

  • Scott Boettger
    Scott Boettger about 4 years

    I have written a WiX installer that works perfectly with Windows XP, but when installing to a Windows 7 box I am running into difficulty with registry entries. I need to add an HKLM entry as well as the registry entry for the program to show in the start menu. Here is the code I am using for both types of entry:

    <!-- Create the registry entries for the program -->
    <DirectoryRef Id="TARGETDIR">
      <Component Id="RegistryEntriesInst" Guid="...">
        <RegistryKey Root="HKLM"
                     Key="Software\$(var.Manufacturer)\$(var.ProductName)"
              Action="createAndRemoveOnUninstall">
          <RegistryValue
              Type="string"
              Name="installed"
              Value="true"
              KeyPath="yes"/>
        </RegistryKey>
      </Component>
      <Component Id="RegistryEntriesVer" Guid="...">
        <RegistryKey Root="HKLM"
                     Key="Software\$(var.Manufacturer)\$(var.ProductName)"
              Action="createAndRemoveOnUninstall">
          <RegistryValue
              Type="string"
              Name="version"
              Value="$(var.ProductVersion)"
              KeyPath="yes"/>
        </RegistryKey>
      </Component>
    </DirectoryRef>
    
    <!-- To add shortcuts to the start menu to run and uninstall the program -->
    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="...">
        <Shortcut Id="ApplicationStartMenuShortcut"
                  Name="$(var.ProductName)"
                  Description="..."
                  Target="[SERVERLOCATION]$(var.Project.TargetFileName)"
                  WorkingDirectory="SERVERLOCATION"/>
        <Shortcut Id="UninstallProduct"
                      Name="Uninstall $(var.ProductName)"
                      Description="..."
                      Target="[System64Folder]msiexec.exe"
                      Arguments="/x [ProductCode]"/>
        <RemoveFolder Id="SERVERLOCATION" On="uninstall"/>
        <RegistryValue
            Root="HKCU"
            Key="Software\$(var.Manufacturer)\$(var.ProductName)"
            Name="installed"
            Type="integer"
            Value="1"
            KeyPath="yes"/>
        </Component>
    </DirectoryRef>
    

    How can I fix this problem?

    On a side note, the registry permissions are the same on the Windows XP and Windows 7 computers.