WIndows Installer将快捷方式放入带有属性的自定义文件夹中 [英] WIndows Installer Putting shortcuts into a custom folder with a property

查看:124
本文介绍了WIndows Installer将快捷方式放入带有属性的自定义文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用InstallShield构建安装程序.这是一个基本的MSI项目(我宁愿对InstallShield没有任何依赖关系,将来可能会使其更难转向WiX).我试图将一些快捷方式放到我想定位为的自定义文件夹中:

I am building an installer with InstallShield. It is a basic MSI project (I'd rather not have any dependencies on InstallShield that might make it more difficult to move to WiX in the future). I am attempting to put some shortcuts into a custom folder that I'd like to locate as:

[INSTALLDIR]\[PROP] Environment

所有快捷方式都将指向[INSTALLDIR]\My.exe [PROP],例如带有命令行参数的已安装可执行文件.

The shortcuts all will point to [INSTALLDIR]\My.exe [PROP], e.g. the installed executable with a command-line parameter.

在InstallShield(它似乎是MSI)中,我不能只是将目录表中的文件夹设置为[PROP] Environment(实际上可以,但是这给了我一个名叫[PROP] Environment的文件夹).我尝试使用35型自定义操作(设置目录),但是它什么都不做,或者给我Could not access network location {expanded property} Environment,具体取决于我在其中得到的顺序.当前,它位于SetupProgress之后的UI序列中.我在UI和Execute序列中的各个位置都尝试过,没有运气.

In InstallShield (and, it appears, MSI) I can't just set the folder in the Directory table to [PROP] Environment (actually I can, but that gives me a folder literally named [PROP] Environment). I've tried to use a type 35 Custom Action (Set Directory) but it either does nothing or gives me Could not access network location {expanded property} Environment, depending on where in the sequence I've got it. Currently it is in the UI sequence after SetupProgress. I've tried it in various locations in both the UI and Execute sequences, with no luck.

如果对解决方案有所帮助,最终目标是能够多次运行安装程序(作为维护或多次安装),但是随后的安装"将仅在新文件夹中添加其他快捷方式,例如:

In case it makes a difference to the solution, the ultimate goal is to be able to run the installer multiple times (either as maintenance or as multiple installations), but subsequent "installs" will simply add additional shortcuts in new folders, e.g.:

PROD Environment
TEST Environment
TRAINING Environment

随时提供WiX解决方案.我发现WiX文档和代码比IS帮助更好地解释了发生的情况.

Feel free to provide a WiX solution. I've found the WiX documentation and code much better at explaining what's going on than the IS help.

UPDATE:如果有帮助,我已经有了一个.Net自定义操作(通过DTF),以防我可以那样做.我正在考虑在其中创建快捷方式的思路.我不确定这将如何影响广告之类的事情,并且我知道我需要添加CA进行卸载才能删除它们.

UPDATE UPDATE:没有帮助.或者,至少没有必要那样做,而且有人可能会争辩说,不应该那样做.

UPDATE UPDATE: It doesn't help. Or, at least, there is no need to do it that way, and, one might argue, it shouldn't be done that way.

推荐答案

如果有点费解,解决方案非常简单.我最初是使用InstallShield创建的,但是稍后,您将超越InstallShield GUI的功能.我将记录MSI表(来自InstallShield DirectEditor),因此应易于转换为WiX.您需要在必要时添加标识符(在需要它们的地方应该很明显):

The solution is pretty simple, if a bit convoluted. I created it initially using InstallShield, but after a point, you're going to stray beyond the capabilities of the InstallShield GUI. I'm going to document the MSI tables (from the InstallShield DirectEditor) so it should be easy to translate to WiX. You'll need to add identifiers where necessary (it should be obvious where you need them):

  1. 在包含快捷方式的功能中创建一个空组件:
    • 在FeatureComponents表中,添加一行:Feature_ = DefaultFeature and Component_ = MyCustomShortcuts
    • 在组件"表中添加一行:Component = MyCustomShortcuts, Directory_ = MYSHORTCUTFOLDER
  1. Create an empty component in the feature that includes the shortcut:
    • in the FeatureComponents table, add a row: Feature_ = DefaultFeature and Component_ = MyCustomShortcuts
    • in the Component table add a row: Component = MyCustomShortcuts, Directory_ = MYSHORTCUTFOLDER
  • 在目录"表中,为您的快捷方式添加一行:Directory = MYSHORTCUTFOLDER, Directory_Parent = TARGETDIR, DefaultDir = .
  • Action = UpdateShortcutFolder, Type = 51, Source = MYSHORTCUTFOLDER, Target = [INSTALLDIR][SHORTCUT_FOLDER_PREFIX] Shortcuts
  • Directory = MYSHORTCUTFOLDER, Name=MyProg~1|MyProgram, Component = MyProgramComponent, Target = [INSTALLDIR]MyProgram.exe

就是这样.快捷步骤是InstallShield UI无法处理事情的地方.幸运的是,从InstallShield Premier 2014开始,它只是忽略了它不了解的内容,因此您将不会在系统配置/快捷方式"视图中看到您的快捷方式.它们将被安装.

That's it. The shortcut step is the point at which the InstallShield UI can't handle things. Fortunately, as of InstallShield Premier 2014, it just ignores what it doesn't understand, so you aren't going to see your shortcuts in the System Configuration/Shortcuts view. They will be installed however.

在我的测试中,卸载时似乎删除了快捷方式,也删除了自定义目录.

In my testing, it appears that the shortcuts are removed, as is the custom directory, when uninstalling.

这篇关于WIndows Installer将快捷方式放入带有属性的自定义文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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