加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

(WiX)每个机器安装的程序文件快捷方式

发布时间:2020-12-13 20:19:00 所属栏目:Windows 来源:网络整理
导读:在 example here之后,我添加了启动我的应用程序的 ProgramMenuFolder的快捷方式. (我的代码实际上更简单,因为我不需要额外的文件夹.) DirectoryRef Id='ProgramMenuFolder' Component Id='cmpStartMenuShortcut' Guid='MY GUID HERE' Shortcut Id='StartMenu
在 example here之后,我添加了启动我的应用程序的 ProgramMenuFolder的快捷方式. (我的代码实际上更简单,因为我不需要额外的文件夹.)
<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='SoftwareCompanyProduct Name'
                   Name='installed' Value='1' KeyPath='yes'/>
  </Component>
</DirectoryRef>

由于我的安装是每台机器(ALLUSERS = 1,Package / @ InstallPrivileges =’raised’和@ InstallScope =’perMachine’),所以ProgramMenuFolder是机器上所有用户的文件夹.

我的问题与注册表值有关.我的理解是,需要为包含快捷方式的组件提供一个KeyPath.样本使用HKCU,它是每个用户的位置.

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

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

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

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

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

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

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

这种快捷方式适用于目前可能无法安装的目标,也不是在调用时.它创建经典的.??lnk快捷方式文件.对于快捷方式来说,您的安装程序不负责,但可能对您的产品的用户有用(例如cmd.exe)的快捷方式.

或者,当目标是无权限的(产品被卸载)时,将卸载正在安装或广告的目标的快捷方式.例如,WiX安装了一个名为WiX文档的wix.chm快捷方式.广告快捷方式的快捷方式元素可以作为File元素的子代.

这是一个手写的例子:

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

要将快捷方式元素插入热输出,请将其传递到XSL转换.片段:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读