aps_brar
Posts: 8
Joined: Wed Jul 29, 2009 6:42 am

Shortcut with Custom action

I am creating a desktop shortcut with a custom action, this shortcut's target is the SHORTCUTDIR i.e. clicking on it opens the folder that has all other shotcuts in "C:\Documents and Settings\All Users\Start Menu\Programs\?????.....", these shortcuts are installed by AI. I am creating the desktop shortcut with a custom action because I need to change its icon depending on a radiobutton value selected by user in the welcome screen. Desktop shortcut has to be created on all users desktop, I get the path for this as follows

Code: Select all

Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("AllUsersDesktop") 
I have added custom action under InstallExecuteSequence > InstallFinalize as I need acces to Installer property SHORTCUTDIR in vbscript to set it as the target for shortcut, It all works fine on Windows XP but on Windows 7 VBScript throws an error but if I run the installer exe by right clicking and selecting "Run as Administrator" it works fine, now my guess is that because I am trying to install the shortcut in AllUserDesktop namespace, Windows 7 needs the script to have admin rights.

How can I Install this shortcut on AllUsersDesktop without having to run the installer with "Run as administrator" option.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Shortcut with Custom action

Hello,

You can try to set your custom action with the "Deferred with no impersonation" execution option and see the result.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
aps_brar
Posts: 8
Joined: Wed Jul 29, 2009 6:42 am

Re: Shortcut with Custom action

I have set the custom action to Deferred with impersonation and moved it to InstallExecuteSequence > Commit because when it was under InstallFinalize then all other execution options were greyed out except for Immediate execution. But doing so was of no avail either as all Installer properties are coming out as empty. I need to be able to access SHORTCUTDIR, APPDIR and another proerty defined by me to figure out user selection from a set of radiobuttons. By the way I am using version 7.7
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Shortcut with Custom action

Hello,

Windows Installer allows only "Immediate" custom actions to access installer properties during the installation. Therefore, a "Deferred", "Rollback" or "Commit" custom action will not have access to installer properties (the properties will be empty when the custom action runs). If you want to use properties in a "Deferred" custom action you need to use the Action Data field.

Here is an article that demonstrates this functionality through a .VBS custom action.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”