“创建快捷方式”复选框
我正在使用 WiX Tool 来创建安装程序。
在创建“开始”菜单和桌面快捷方式时,我需要安装程序将其设为可选。
类似于:[ ]您想创建开始菜单快捷方式吗?
这可能吗?
I'm using the WiX Tool to create an installer.
I need the installer to make it optional, when creating Start Menu and Desktop shortcuts.
Something like: [ ] Do you want to create a start menu shortcut?
Is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这绝对是可能的。总体思路是使快捷方式组件以属性为条件,然后自定义 UI 以将复选框连接到该属性。
所有这些都在 Wix 教程 中进行了描述(尽管不是针对您的具体示例),这是一本富有洞察力的读物。但这里有一些适合您的情况的更具体的代码示例:
添加属性
创建一个可以将复选框挂接到的属性。在 .wxs 文件中,添加一个
Property
来存储该值。添加一个条件
将一个
Condition
添加到安装快捷方式的组件,因此它以以下值为条件:您的新INSTALLSHORTCUT
属性。添加复选框
您需要自定义一个对话框以将复选框添加到 UI 并将其挂接到
INSTALLSHORTCUT
属性。我不会在这里详细介绍所有细节,但这里有一个很好的教程:用户重新访问界面您需要下载 wix 源代码树以获取您正在使用的 UI 的 .wxs 文件。例如,要将复选框添加到
WixUI_InstallDir
UI 中的InstallDir
对话框,您需要下载WixUI_InstallDir.wxs
和InstallDirDlg.wxs
。将它们添加到您的 Wix 项目中并重命名它们(例如,Custom_InstallDir.wxs
和Custom_InstallDirDlg.wxs
)。编辑
指定一个新的Custom_InstallDirDlg.wxs
以添加复选框。也为Id
:编辑
Custom_InstallDir.wxs
以使用自定义的InstallDirAndOptionalShortcut
对话框:最后,在主 .wxs 文件中引用您的自定义 UI:
Yes, this is definitely possible. The general idea is to make the shortcut component be conditional on a property, then customize your UI to connect a checkbox to that property.
All of this is described (though not for your specific example) in the Wix Tutorial, an insightful read. But here are some more specific code samples for your case:
Add a Property
Create a property that you can hook the checkbox up to. In your .wxs file, add a
Property
to store the value in.Add a Condition
Add a
Condition
to the component that installs the shortcut, so it's conditional on the value of your newINSTALLSHORTCUT
property.Add the Checkbox
You need to customize a dialog to add a checkbox to the UI and hook it up to the
INSTALLSHORTCUT
property. I won't go into all the details here, but there's a good tutorial here: User Interface RevisitedYou'll need to download the wix source tree to get the .wxs files for the UI you are using. To add the checkbox to the
InstallDir
dialog in theWixUI_InstallDir
UI, for example, you would downloadWixUI_InstallDir.wxs
andInstallDirDlg.wxs
. Add them to your Wix project and rename them (e.g.,Custom_InstallDir.wxs
andCustom_InstallDirDlg.wxs
).Edit
Custom_InstallDirDlg.wxs
to add your checkbox. Give the<Dialog>
a newId
too:Edit
Custom_InstallDir.wxs
to use the customizedInstallDirAndOptionalShortcut
dialog:Finally, reference your customized UI in your main .wxs file:
在复选框单击事件或下一个按钮单击上,您可以调用自定义操作来创建快捷方式。
On the checkbox click event or on the next button click you can call an custom action to create shortcuts.