【发布时间】:2012-08-05 19:09:13
【问题描述】:
如何通过 wix 设置项目在桌面上创建快捷方式?
【问题讨论】:
-
这就是我对这些天这么多微软“技术”的感受。这一评论是在将近三年后发表的。很明显,最先进的技术并没有提高。
标签: wix installation windows-installer shortcut
如何通过 wix 设置项目在桌面上创建快捷方式?
【问题讨论】:
标签: wix installation windows-installer shortcut
快捷方式是非广告的,希望这对某人有所帮助。 请记住将组件放在您的功能标签中。
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="DesktopFolder" Name="Desktop">
<Component Id="ApplicationShortcutDesktop" Guid="*">
<Shortcut Id="ApplicationDesktopShortcut"
Name="Text under your icon"
Description="Comment field in your shortcut"
Target="[MYAPPDIRPROPERTY]MyApp.exe"
WorkingDirectory="MYAPPDIRPROPERTY"/>
<RemoveFolder Id="DesktopFolder" On="uninstall"/>
<RegistryValue
Root="HKCU"
Key="Software\MyCompany\MyApplicationName"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
</Directory>
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="MyCompany" Name="MyCompany">
<Directory Id="MYAPPDIRPROPERTY" Name="MyAppName">
<!-- main installation files -->
</Directory>
</Directory>
</Directory>
</Directory>
【讨论】:
Guid="*" 改为自动生成 guid,或使用 {PUT-GUID-HERE}
我相信使用“当前用户”(HKCU) 注册表项作为密钥路径会导致多用户机床出现问题。因为注册表项只为当前用户创建,当其他用户登录时,安装的自动修复就会启动。
【讨论】:
经过太多努力,我是这样用的:
<Product ...>
<Feature Id="ProductFeature" Title="SetupProject" Level="1">
...
...
<ComponentRef Id="cmpDesktopShortcut" />
</Feature>
<Component Id="cmpDesktopShortcut" Guid="PUT-GUID-HERE" Directory="DesktopFolder" >
<Shortcut Id="MyDesktopShortcut"
Name="Setup Project"
Description="Opens the program."
Directory="DesktopFolder"
Target="[INSTALLFOLDER]App.exe"
WorkingDirectory="INSTALLFOLDER"/>
<RegistryValue Root="HKCU" Key="Software\My Company\Sample Application" Name="installed" Type="integer" Value="1" KeyPath="yes" />
</Component>
</Product>
【讨论】:
documentation 似乎更容易。
首先,您必须指向您的 DesktopFolder,
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="DesktopFolder" Name="Desktop"/>
然后你应该为你想要创建快捷方式的文件创建快捷方式组件。
<Component Id="PutYourComponentIdHere" Directory="FileDirectory" Guid="*">
<File Id="NotYourComponentId" KeyPath="yes" Source="..\YourFileSource\YourExecutable.exe">
<Shortcut Id="desktopServer" Directory="DesktopFolder" Name="YourShourtcutName" WorkingDirectory='WhereShouldYourShortcutPoint' Advertise="yes"/>
</File>
</Component>
它对我有用。我需要放图标,但这很容易。希望它有效。
【讨论】:
例如,谢谢。在 WIX 3.8 中,它仍然提出: “错误 3 ICE43:组件...具有非广告快捷方式。它应该使用 HKCU 下的注册表项作为其 KeyPath,而不是文件。”
所以我在一个具有特征的文件中这样做了:
<Component Id="cmp79F6D61F01DD1060F418A05609A6DA70"
Directory="dirBin" Guid="*">
<File Id="fil34B100315EFE9D878B5C2227CD1454E1" KeyPath="yes"
Source="$(var.SourceDir)\FARMS.exe" >
<Shortcut Id="DesktopShortcut"
Directory="DesktopFolder"
Name="FARMS $(var.FarmsVersion)"
Description="Local Land Services desktop application"
WorkingDirectory="INSTALLFOLDER"
Icon="FARMS.exe"
IconIndex="0"
Advertise="yes" >
<Icon Id="FARMS.exe" SourceFile="$(var.SourceDir)\FARMS.exe" />
</Shortcut>
</File>
</Component>
并在带有产品定义的文件中提到桌面文件夹:
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="DesktopFolder" Name="Desktop" />
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="FARMS" >
</Directory>
</Directory>
</Directory>
</Fragment>
【讨论】:
我觉得我的方法更简单,不需要你创建注册表项:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="DesktopFolder" SourceName="Desktop" />
<Directory Id="MergeRedirectFolder">
<Component Id="MyExeComponent" Guid="{PUT-GUID-HERE}">
<File Id="MyExeFile" Source="$(var.ExeSourcePath)" KeyPath="yes">
<Shortcut
Id="DesktopShortcut"
Directory="DesktopFolder"
Name="$(var.ShortcutName)"
WorkingDirectory="MergeRedirectFolder" />
</File>
</Component>
</Directory>
</Directory>
【讨论】:
Directory_ 字段引用特殊的 DesktopFolder 文件夹,Target 字段携带值 [#<ID-of-MyExeFile>]。我看到的唯一缺点是文件和快捷方式都是单个组件的一部分,因此不能单独安装一个。显然,没有目标文件安装快捷方式是没有意义的,但现在你也不能有“将快捷方式放在桌面上”选项。