Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Conditionally create shortcut based on the user selection

Tue Oct 12, 2021 1:36 pm

Hello,

To create a shortcut you can follow the steps from the create shortcut tutorial. If the shortcut should be conditionally created, then add the ShortcutsDlg. Based on the checkbox state, the shortcuts placed in the corresponding folders will be created or not.

Here we have 2 limitations. To conditionally create a shortcut we need to have the ShortcutsDlg. You cannot condition each shortcut to be created, instead all shortcuts will be created or not in a certain location e.g. Desktop based on the corresponding checkbox.

To be able to conditionally create a shortcut without using the predefined ShortcutsDlg, here's what you need to do:

1) In the Files and Folders view, create an external shortcut to your .EXE package:

External shortcut.PNG
External shortcut.PNG (198.82KiB)Viewed 264889 times

We cannot use the installed file shortcut because the shortcut cannot be moved from the component of that file.


2) Create a dummy registry to use its component to attach the external shortcut

By default, the external shortcut does not have its own component, thus a dummy component needs to be created and attach the external shortcut to it.

Registry creation.PNG
Registry creation.PNG (63.95KiB)Viewed 264889 times

3) Attach the external shortcut to its component
  • For this, navigate to the Organization view and select the component of the registry
  • Then locate the component of the shortcut and drag-and-drop it under the component of the registry
  • Condition its creation based on the property attached to the checkbox
To navigate between resources (registry, files) and components use the F8 keyboard shortcut.
Component creation.png
Component creation.png (40.46KiB)Viewed 264889 times

The sample project is attached to this thread, so if you are interested to take a look directly at my project, you are more than welcome to download the ZIP file.

Hope you will find this information helpful and let us know if you want to see more samples from our side.

All the best,
Dan
Attachments
External shortcut sample.zip
(362.09KiB)Downloaded 2267 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Sample Projects”