WiX will not add HKLM registry setting during Windows 7 install
Asked Answered
V

3

33

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.

Vulturine answered 10/12, 2009 at 16:4 Comment(1)
I was able to find where the Registry entries were going. They are actually being placed under the Wow6432Node. Is there a way to get it placed under the normal Software Registry Key rather than Software\Wow6432Node?Vulturine
V
34

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.

Vulturine answered 10/12, 2009 at 19:28 Comment(1)
Maybe worth noting that you find the entry under HKLM\Software\Wow6432Node[var.Manufacturer][var.ProductName]Omega
A
20

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.

Astyanax answered 5/4, 2010 at 7:33 Comment(1)
I do this, but it basically makes you put the registry settings twice -- once with win64=yes and condition VersionNT64 and the other with no and NOT VersionNT64 -- to avoid typing them twice you can use an include file, and then just include the same chunk twice -- and if the ICE80 warnings are bugging you, you can suppress them in the project property pages.Wrong
N
5

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.

Negrito answered 10/12, 2009 at 16:51 Comment(1)
This was quite helpful and gave me a further understanding of the change from 32 to 64 bit systems.Vulturine

© 2022 - 2024 — McMap. All rights reserved.