WiX 在 Windows 7 安装期间不会添加 HKLM 注册表设置

发布于 2024-08-14 17:13:40 字数 2089 浏览 3 评论 0 原文

我编写了一个与 Windows XP 完美配合的 WiX 安装程序,但是当安装到 Windows 7 机器时,我在注册表项方面遇到了困难。我需要添加 HKLM 条目以及注册表条目,以便程序显示在开始菜单中。这是我用于两种类型条目的代码:

<!-- 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>

如何解决此问题?

另外,Windows XP 和 Windows 7 计算机上的注册表权限是相同的。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浪推晚风 2024-08-21 17:13:40

我已经弄清楚为什么会发生这种情况。

由于 WiX 安装程序是在 x86 平台上编译的,因此 Windows 7 将其选择为具有 32 位注册表项的 32 位安装程序。 Windows 7 64 位通过执行我所看到的操作来处理 32 位注册表项。

该程序仍处于注册状态;它只是不在注册表的 64 位部分中。在 x64 平台下编译它,同时进行必要的更改以使其适用于 64 位系统(ProgramFileFolder 变为 ProgramFiles64Folder 等),它会将内容放在正确的位置。

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.

念三年u 2024-08-21 17:13:40

感谢您基本上为我解决了这个问题!

我只是想补充一点,您不一定需要将所有内容更改为 x64 才能正常工作,只需将有问题的组件标记为 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>

请注意 Win64="yes",这就是写入注册表的 64 位区域所需的全部内容。 VersionNT64 条件存在,因此该组件只能安装在 x64 系统上。

就我而言,这会发出 ICE80 警告,因为我想在 32 位 ProgramFilesFolder 中安装 64 位组件。我很高兴忽略这些,因为我的主应用程序不是 x64,只有 shell 扩展是,而且我不想将 shell 扩展放在它自己的特殊文件夹中。

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.

无声静候 2024-08-21 17:13:40

Windows 7 处理某些注册表项的方式存在一些差异。从 Windows 7 开始删除了注册表反射。我不确定这是否符合您在这里看到的内容,但请查看 此链接了解更多信息。

此外,如果您使用的是 64 位版本的 Windows 7,您可以通过参考 MSDN 64 位 Windows 编程指南

此外,如果您需要根据 Windows 风格(XP、Vista、7 等)将不同的注册表项安装到不同位置,则 此堆栈溢出问题也为您提供了答案。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文