timryder
Posts: 5
Joined: Wed Feb 16, 2011 5:35 pm

Create Shortcut based on checkbox status

Hello all,

I'm not very good yet at this scripting stuff, but basically what I want to do is create a shortcut in the windows startup directory for all users if a checkbox I have on on my of dialogs prior to install action is checked. I have a shortcut for my application already created and I can use that exact same one in the windows startup directory, but I can't quite figure out how to do it based upon checkbox.

Any help would be appreciated!
Daniel
Posts: 8268
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Create Shortcut based on checkbox status

Hi,

Please keep in mind that a check box control has associated a property name (i.e. MY_CHECKBOX) and a value (i.e. checked). When the check box is checked then MY_CHECKBOX property will contain the "checked" value.
If you want to condition installation of your shortcut depending of the check box state you should condition installation of a dummy component, that should contain your shortcut, from "Organization" page. So, you should create a component containing dummy resource (i.e. a registry or a file) that will contain your shortcut. The component installation will have the following install condition: MY_CHECKBOX = "checked". A shortcut to an installed file can not be moved from its target file component. So, you should create your shortcut as a shortcut to an external file in order to move it in a dummy component.

In order to achieve what you want this is what you should do:
- Go to the "Registry" page and create a dummy key (i.e. My_Key) using [New Key] toolbar button. Here create a dummy registry (i.e My_registry) using [New Value] toolbar button.
- In Files and Folders view select the file that you want to have a shortcut in the windows startup directory. From its context menu choose "New Shortcut To" -> "External File...". In the new dialog set the following fields :
Name: Your shortcut name
Arguments: Your arguments file
Shortcut Target: Path to your shortcut file
Shortcut Folder: StartupFolder

- Select your shortcut and from its context menu choose "Go To Component" or simply press F8 shortcut key.
- Drag your shortcut in the My_Key component (your dummy component). Select My_Key component and in the "Condition" field from the "Component Properties" right pane set the following condition:
MY_CHECKBOX = "checked"
- In the "Dialogs" page create a check box control and set it as follows:
Property Name: MY_CHECKBOX
Value: checked


Regards,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
timryder
Posts: 5
Joined: Wed Feb 16, 2011 5:35 pm

Re: Create Shortcut based on checkbox status

One thing missed but I did eventually figure out was that I had to also create that property which the checkbox was using.
Which just in case someone else reads this later on, is done on the "Install Parameters" page. Create the property and set the default value to something besides "checked" like "notChecked" for example.

But thanks so much for your help! I was able to walk through it and accomplish what I was looking for with your instructions.
timryder
Posts: 5
Joined: Wed Feb 16, 2011 5:35 pm

Re: Create Shortcut based on checkbox status

As sort of a side question, can this action be done on the final closing dialog? I have it currently being done before the installation continues. I have seen other software installers which feature this button after the installation on the last page and thought it may be nice to do it here as well.

Thanks
Daniel
Posts: 8268
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Create Shortcut based on checkbox status

Hi,

You can not have this option on the "ExitDialog" because package resources (registries, files, shortcuts) will be installed or not (based on conditions) before occurrence of this dialog. If you want this you should create your own custom action that will add a shortcut after install execution stage.

Regards,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”