jasoncd
Posts: 49
Joined: Thu Jan 29, 2009 4:48 pm

Changing Shortcut working directory based

I want to change the working directory of a shortcut based on the build. Normally it will be PersonalFolder, but for one build it will be a subdirectory of the PublicDocumentsFolder. I haven't found a way to do this at build time. Do I have to create a custom action to set this property based on whether or not the feature is installed? If so, could you provide some guidance? Thanks.
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Changing Shortcut working directory based

Hello,

To achieve what you need you can use your own custom property (MY_SH_DIR) in the "Working directory" field.Then, you should use several "Set installer properties" custom actions which will set your "MY_SH_DIR" property to the desired folder path depending on the value of the "AI_BUILD_NAME" property. You should have as many "Set installer properties" custom action as build configurations you have.

Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
jasoncd
Posts: 49
Joined: Thu Jan 29, 2009 4:48 pm

Re: Changing Shortcut working directory based

Thank you. Took several tries, but got it working. The key was to place the custom actions after the Paths Resolution action. For anyone who finds this, below are the steps I did, which may not necessarily be the best, but they worked for me. Change names to whatever.

Create property: SHORTCUT_WORKING_DIR
Default value: C:\ (value doesn't seem to matter but needs to be a valid path format)

For the shortcut, set the Working directory to: SHORTCUT_WORKING_DIR

Create a custom action, SetPropertyPublic, after Paths Resolution in the Install Execution Stage.
Property: SHORTCUT_WORKING_DIR
Value: [PersonalFolder]
Condition: AI_BUILD_NAME="Public"

Create a custom action, SetPropertyWorkshop, after Paths Resolution in the Install Execution Stage.
Property: SHORTCUT_WORKING_DIR
Value: [SamplesDirectory] (location of my samples folder in Files and Folder)
Condition: AI_BUILD_NAME="Workshop"
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Changing Shortcut working directory based

You're always welcome.

Thank you for posting your complete solution. Certainly this will be useful for future users.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”