问题
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
The shortcuts all will point to [INSTALLDIR]\My.exe [PROP]
, e.g. the installed executable with a command-line parameter.
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
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: If it helps I've already got a .Net Custom Action (via DTF) in case I can do things that way. I'm thinking along the lines of creating the shortcuts in there. I'm not sure how that will impact things like advertising, and I know I'll need to add a CA for uninstall to remove them.
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.
回答1:
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):
- 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
- in the FeatureComponents table, add a row:
- Create the directory
- in the Directory table add a row for your shortcuts:
Directory = MYSHORTCUTFOLDER, Directory_Parent = TARGETDIR, DefaultDir = .
- in the Directory table add a row for your shortcuts:
- Add a Custom Action, type 51 (Set Property) to name the folder according to the public property you would like to control the name:
Action = UpdateShortcutFolder, Type = 51, Source = MYSHORTCUTFOLDER, Target = [INSTALLDIR][SHORTCUT_FOLDER_PREFIX] Shortcuts
- Create your shortcut. In the Shortcut table add a row:
Directory = MYSHORTCUTFOLDER, Name=MyProg~1|MyProgram, Component = MyProgramComponent, Target = [INSTALLDIR]MyProgram.exe
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.
来源:https://stackoverflow.com/questions/30667275/windows-installer-putting-shortcuts-into-a-custom-folder-with-a-property