Conditional shortcuts · 26 December 2005, 11:07

Sometimes you want to create a shortcut that’s conditional. For example to create a shortcut to a user’s startup folder so the application starts up when the user starts up their computer. Seems like a simple task. As with most things MSI you soon start running into problems.

1) There’s no startup folder in the “File System on Target Machine” tree.

Thankfully this is easy to do. First go to filesystem view (right click on the setup project -> Views -> File System). Then right click on the tree -> Add Special Folder -> User’s Startup Folder

2) There is no page to ask the user if they want the program to automatically start.

Again easy to do once you know how. Go to User Interface View (right click on the setup project -> Views -> Interface View). Then right click on the “Start” node and select “Add Dialog”. Choose “Checkboxes (A) dialog and drag it to where you want it in the stream of dialogs.

Fill out the banner text, body text, Checkbox1 labels how you want them to appear. Make certain that Checkbox1Visible is true and all of the others (Checkbox234Visible) are false. Name Checkbox1Property to be something meaningful like AUTOSTARTCHECKBOX. This will be needed later when you create the condition.

3) Create a conditional shortcut to the start menu.

This is a bit tricky. When you add a file to a project (e.g. Primary output from …) the first property is “Condition” which allows you to tie it to a condition like a checkbox. However, if you create a shortcut to it (right mouse -> Create Shortcut to Primary output from …) there’s no condition property field.

This is because a shortcuts are linked to the files that they point to. If the file condition is not satisfied then the shortcut will not be created either. So what is an install engineer to do? You don’t want to make your main executable optional. Or do you?

The solution is you need to create two “Primary outputs” in your application directory. One that is conditional and the other that is not. So create a second “Primary output from ….” in the Application Folder. In its condition field put AUTOSTARTCHECKBOX or whatever you named your checkbox. Then create a shortcut to it and drag it to the “User’s Startup Folder”.

Presto! A conditional shortcut to the statup menu!

* * *