(WiX) 每台机器安装的程序文件快捷方式 [英] (WiX) Program files shortcut for per-machine install

查看:26
本文介绍了(WiX) 每台机器安装的程序文件快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照示例,我添加了ProgramMenuFolder 启动我的应用程序.(我的代码实际上更简单,因为我不需要额外的文件夹.)

Following the example here, I added a shortcut to the ProgramMenuFolder that launches my application. (My code is actually simpler because I don't need the extra folder.)

<DirectoryRef Id='ProgramMenuFolder'>
  <Component Id='cmpStartMenuShortcut'
             Guid='MY GUID HERE'>
    <Shortcut Id='StartMenuShortcut'
              Name='$(var.ProductName)'
              Icon='MainIcon.ico'
              Description='$(var.ProductName)'
              Target='[ClientDir]myapp.exe'
              WorkingDirectory='ClientDir'/>
    <RegistryValue Action='write' Type='integer' Root='HKCU'
                   Key='Software\Company\Product Name'
                   Name='installed' Value='1' KeyPath='yes'/>
  </Component>
</DirectoryRef>

由于我的安装是按机器进行的(ALLUSERS=1、Package/@InstallPrivileges='elevated' 和 @InstallScope='perMachine'),因此 ProgramMenuFolder 是机器上所有用户的文件夹.

Since my installation is per machine (ALLUSERS=1, Package/@InstallPrivileges='elevated', and @InstallScope='perMachine') the ProgramMenuFolder is the folder for all users on the machine.

我的问题与注册表值有关.我的理解是,只需为包含快捷方式的组件提供 KeyPath 即可.该示例使用 HKCU,这是每个用户的位置.

My question has to do with the registry value. My understanding is that it's needed simply to provide a KeyPath for the component that contains the shortcut. The sample uses HKCU, which is a per-user location.

将每个用户的值用作每个机器组件的 KeyPath 是不是一个错误?

如果一台机器有两个管理员,管理员 #1 安装产品,管理员 #2 尝试修复,那么 Windows Installer 将看不到注册表值并认为快捷方式丢失,它将安装重复项,对吗?

If a machine has two admins, and admin #1 installs the product, and admin #2 attempts a repair, then Windows Installer won't see the registry value and think that the shortcut is missing and it will install a duplicate, right?

所以我尝试将 RegistryValue/@Root 更改为 HKLM,但随后 WiX 抱怨:

So I tried changing the RegistryValue/@Root to HKLM, but then WiX complains:

错误 LGHT0204:ICE38:组件 cmpStartMenuShortcut 安装到用户配置文件.[原文如此] KeyPath 注册表项必须属于 HKCU.

error LGHT0204 : ICE38: Component cmpStartMenuShortcut installs to user profile. It's[sic] KeyPath registry key must fall under HKCU.

错误 LGHT0204:ICE43:组件 cmpStartMenuShortcut 有未公布的快捷方式.[原文如此] KeyPath 注册表项应该属于 HKCU.

error LGHT0204 : ICE43: Component cmpStartMenuShortcut has non-advertised shortcuts. It's[sic] KeyPath registry key should fall under HKCU.

错误 LGHT0204:ICE57:组件cmpStartMenuShortcut"具有每个用户和每个机器的数据以及每个机器的 KeyPath.

error LGHT0204 : ICE57: Component 'cmpStartMenuShortcut' has both per-user and per-machine data with a per-machine KeyPath.

我不明白为什么密钥必须在 HKCU 下.

I don't understand why the key must be under HKCU.

推荐答案

这种快捷方式适用于现在和调用时都可能不会安装的目标.它创建经典的 .lnk 快捷方式文件.它对于您的安装程序不负责的目标的快捷方式很有用,但可能对您的产品用户使用(例如 cmd.exe)有用.

That style of shortcut is for a target that might not be installed now nor at the time it is invoked. It creates the classic .lnk shortcut file. It is useful for shortcuts to targets that your installer is not responsible for but might be useful for users of your product to use (e.g. cmd.exe).

或者,当目标未发布广告(产品已卸载)时,您正在安装或广告的目标的快捷方式将被卸载.例如,WiX 安装了一个名为 WiX 文档的 wix.chm 快捷方式.广告快捷方式的 Shortcut 元素可以成为 File 元素的子元素.

Alternatively, a shortcut for a target you are installing or advertising will be uninstalled when the target is unadvertised (product is uninstalled). For example, WiX installs a shortcut to wix.chm called WiX Documentation. The Shortcut element for an advertised shortcut can be made a child of the File element.

这是一个手写的例子:

<Component Id="ProductComponent">
   <File Source="$(var.ConsoleApplication1.TargetPath)" KeyPath="yes">
     <Shortcut Id="$(var.ConsoleApplication1.TargetName)Shortcut" 
               Name="$(var.ConsoleApplication1.TargetName)" 
               Advertise="yes"
               Description="Starts $(var.ConsoleApplication1.TargetName)"
               Directory="ProgramMenuFolder" />
   </File>
</Component>

要将 Shortcut 元素插入 heat 的输出,请将路径传递给 XSL 转换.片段:

To insert the Shortcut element into heat's output, pass it the path to an XSL transform. Snippet:

<xsl:template match="wix:File[contains(@Source,'\myapp.exe')]">
  <xsl:copy-of select="." />
  <Shortcut Id='StartMenuShortcut'
          Advertise="yes"
          Name='$(var.ProductName)'
          Icon='MainIcon.ico'
          Description='$(var.ProductName)'
          WorkingDirectory='ClientDir'/>
</xsl:template>

这篇关于(WiX) 每台机器安装的程序文件快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆