elou
Posts: 96
Joined: Tue Apr 14, 2015 9:12 am

ShortcutsDlg should set options conditionally

Hello,
I'm using ShortcutsDlg to create my application shortcuts. It works great.
Now I'd like to make the default settings dependings on some parameters.
* The Desktop Icon should be per default activated for the first installation, but not for the second (but it should not also been removed!).
* I would also like the set the value (if a shortcut should be installed or not) with a start parameter, when installer runs without UI.
How can I achieve that?

[UPDATE]
I've found that I could use AI_DESKTOP_SH="1" or AI_DESKTOP_SH="0", but I would also like to be able to overwrite the Icon only if it is already present.
If the user as deleted the Icon on a previous Version, ich should not be installed on the desktop with the newer version.
[/UPDATE]

Regards,
Éric.
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: ShortcutsDlg should set options conditionally

Hello,

From what I can tell you need to preserve the checkbox value from the first installation when performing a major upgrade. If the user decides to uncheck the checkbox on first time install, when performing an upgrade it should be unchecked by default.

This could be implemented in the following way:

In the old project :

- go to "Registry" page, create a new string registry value configured to store the formatted reference "[AI_DESKTOP_SH]"

In the upgrade project:
-go to "Search" page and create a new search configured to search in the registry for the registry value from the above. The result will be stored in a property named by default "RESULT_PROPERTY"
-go to "Dialogs" page and create a new "Set Installer Property value" Init Event configured in the following way:

Code: Select all

"Property: AI_DESKTOP_SH"
"Argument: [RESULT_PROPERTY]"
I would also like the set the value (if a shortcut should be installed or not) with a start parameter, when installer runs without UI.
How can I achieve that?
You could achieve this by setting the AI_DESKTOP_SH property when installing the package silently. If this property is empty the shortcut will not be installed.You could use a command line similar to:

Code: Select all

setup.msi /qn AI_DESKTOP_SH=""
Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
elou
Posts: 96
Joined: Tue Apr 14, 2015 9:12 am

Re: ShortcutsDlg should set options conditionally

Hello,
thx for the idea of using the registry.
It was far away difficult to implements as it has been describe because the AI_DESKTOP_SH value is {} (not defined) when the Icon is not activated.
As it's not possible to easily detect such entry in the registry with AI, I've used two properties for READ and WRITE the values, so that "0" and "1" are stored in the registry and {} or "1" or default value are affected to AI_DESKTOP_SH.
The other thing is that the checkboxes are reseted each time the user is switching back to the shortcuts Dialog, which is not really what the user expect.
It's better to set the AI_DESKTOP_SH value at start of the wizard.
Regards, Éric.
Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: ShortcutsDlg should set options conditionally

Hello Eric,

You are welcome!
Thank you for sharing your implementation.

Just let me know if you have any other questions.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”