cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ishanu
Level 3

Create $PRODUCT_NAME$ folder automatically to user selected installation location

Hi,

I have configured a installer project.

Now the default install location is Ex: C:\Program Files\$PRODUCT_NAME$

When the user select a custom install location it would be Ex: F:\test

In this case if the user accidentally select a folder containing other files/folders, when the application is uninstalled, all the contents in the folder will be deleted.

This is a major issue.

What I wanted to do is, add the $PRODUCT_NAME$ folder to custom install location, when the user select a custom install location.

So that the final custom install location would be Ex: F:\test\$PRODUCT_NAME$

Please help and guide to achieve this in the installer configuration window or adding a plugin if impossible.

Thank you.

0 Kudos
(1) Reply
VineethaNair
Level 6

Hi @ishanu ,

When the user select a custom install location containing other files/folders, when the application is uninstalled, only the the installed application will be deleted.

However we can use Custom Code to modify the custom install folder. Develop custom code to extract the value of $USER_INSTALL_DIR$ variable and concatenate it with the extracted value of $PRODUCT_NAME$ variable. Set the concatenated  value to $USER_INSTALL_DIR$ variable using  InstallerProxy setVariable()  and configure Execute Custom Code action. 

Have attached custom code Sample.zip which include a sample InstallLocationModifier class.
Steps to configure Execute Custom code action:
Add "Execute Custom Code" action after the "Choose Install Folder" panel in 
Sequence->PreInstall phase
Configure the path of attached  Sample.zip in the action and set the class name as InstallLocationModifier.
Build and run the installer & set a custom install location.

Screen shot & sample custom code attached.
Hope this helps.

0 Kudos