views:

1338

answers:

3

Good Morning,

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. What I need to do is add a 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>

Any help/suggestions that can be given will be appreciated. On a side note the registry permissions are the same on the XP and 7 computers.

Thanks

+3  A: 

There are some differences to how Windows 7 handles certain registry keys. Registry reflection was removed starting with Windows 7. 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 question also has an answer for you.

Mat Nadrofsky
This was quite helpful and gave me a further understanding of the change from 32 to 64 bit systems.
Scott Boettger
+4  A: 

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 thing in the right place.

Scott Boettger
+2  A: 

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.

Jacob Stanley