I am working on a Setup Project in Visual Studio, and I would like the user to be able to specify whether to create a Desktop Shortcut and/or a Start Menu shortcut to the program by using checkboxes.
I am able to have the installer to create working shortcuts in the appropriate locations, and I added a dialog containing checkboxes to the installer; however, I am unable to have the creation (or lack thereof) of these shortcuts connected to the status of these checkboxes.
I'm assuming that I need to set "Condition" properties, but I'm not sure of the specific syntax. Is this possible, and if so, how would I go about accomplishing this?
Open FileSystem editor and go the User's Desktop folder. Right click with the mouse and select Create New Shortcut. You will be presented with a dialog that allows you to select for instance the application folder (on the target machine). When you double click on this you see what is inside that folder.
Add the custom action Switch back to your installer project and select the gadget installer project in Solution Explorer. On the View menu, point to Editor, and then click Custom Actions. The Custom Actions Editor appears. In the Custom Actions Editor, select Install.
The linked feedback item said:
In the case that you want the checkbox to only control whether the shortcut installs, and not its target, there is currently no solution in Visual Studio setup projects, and this is best accomplished either through extra MSI knowledge and a post-build script to manually modify your MSI after each build, or by migrating to a more advanced (and flexible) tool for setup development (for example, Windows Installer XML).
You can't do it within the VS point-and-click interface, but it's actually not difficult to do what you want with a simple custom action.
Define a script, in VBScript or JavaScript. You can set the custom action to run based on any condition, including a checkbox in a dialog.
Inside the script, you parse the input, and create the shortcut. I used the convention to separate args to the script with a | character, so this is how I parse:
var parameters = Session.Property("CustomActionData").split("|");
var targetDir = parameters[0];
var checkBoxState = parameters[1];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With