rafizan46
Posts: 62
Joined: Wed Mar 29, 2017 2:45 pm

Make APPDIR persistent everytime i launch setup

Tue Sep 10, 2019 7:00 am

Hi, is it possible for me to make APPDIR persistent everytime i launch setup? Every time i try to install, i change the install path to drive D, but when i launch the setup again at later time, the APPDIR return to default location. Is anything i can do about this ? Thank you :)

Catalin
Posts: 6506
Joined: Wed Jun 13, 2018 7:49 am

Re: Make APPDIR persistent everytime i launch setup

Tue Sep 10, 2019 8:52 am

Hello,

Yes, it is possible to make force the APPDIR property to be a persistent property.

Here is how it can be achieved:

1. If you go to the "Registry" page, you can notice that the [APPDIR] property is saved into the registries at the following path:

HKLM:\SOFTWARE\<Manufacturer>\<ProductName> --> the "Path" value.

where "Manufacturer" is the "Publisher" field from "Product Details" page and "ProductName" is the "Name" field from the same page.

You can run a test installation to check this first hand.

Taking in consideration that this value is saved into the registries on every installation, we can use that in our advantage to use the value previously used for our current installation. To do so, you can proceed as it follows:

2. go to "Search" page and:

2.a) create a new search by right clicking on "Target Computer" --> "New Search"

2.b) now click on the earlier created search --> "Add search location" --> "Registry"

If a basic project (where Manufacturer=Your Company and ProductName=Your Application), the search can look like this:
Annotation 2019-09-10 104259.png
Annotation 2019-09-10 104259.png (21.62KiB)Viewed 10925 times
After creating and testing the search, we can simply use a "SetProperty" custom action to set our current APPDIR to the value found in the registries (the APPDIR used in a previous installation). To do so, you can proceed like this:

3. go to "Custom Actions" page and:

3.a) add a "SetProperty" custom action with sequence (by pressing the "Add custom action with sequence" button which is placed to the right side of the custom action's name)

3.b) the custom action should look like this:
Annotation 2019-09-10 104840.png
Annotation 2019-09-10 104840.png (63.85KiB)Viewed 10925 times
where [RESULT_PROPERTY] is the property that stores our search value. One important thing to do here is to uncheck the "First time install" option from under the "Dialogs Stage Condition" (we do not want this to execute on the first time install since we do not have anything to search in the registry in the first place).

Additionally, this custom action should be shared between the two execution stages (Wizard Dialogs Stage and Install Execution Stage). To do so, simply SHIFT + drag and drop it.

After doing so, please make sure that the second custom action also has the "First time install" option unchecked.

The sharing is done mainly due to the fact that, during a silent installation, the Wizard Dialogs Stage is skipped, and the property will not be set.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

rafizan46
Posts: 62
Joined: Wed Mar 29, 2017 2:45 pm

Re: Make APPDIR persistent everytime i launch setup

Wed Sep 11, 2019 11:10 pm

So, every time I want change the install path, I must go to registry by REGEDIT and modify the string ? Because I already try what you suggest and look like i cant change the install path using the browse button. The path edit box always shows the same path value every time i try to change install location.

rafizan46
Posts: 62
Joined: Wed Mar 29, 2017 2:45 pm

Re: Make APPDIR persistent everytime i launch setup

Thu Sep 12, 2019 9:34 am

Hi, I already try everything since yesterday, but no luck. Can you send me 1 sample project file for me to see what im wrong and what im missed?

Catalin
Posts: 6506
Joined: Wed Jun 13, 2018 7:49 am

Re: Make APPDIR persistent everytime i launch setup

Mon Sep 16, 2019 1:37 pm

Hello,

First of all, please accept my apologies for the delayed reply.

Indeed, I have forgot to mention one thing in my last thread.

Basically, the custom action that is scheduled in the "Install Execution Stage" will execute (after you set your APPDIR property using the "Browse" button) and will rewrite the property.

In order to avoid such a behavior, please go to "Custom Actions" page --> click on the Custom Action that is scheduled in the "Install Execution Stage" --> under "Execution Stage Condition" please click on the "Advanced execution scenarios..." and then select the "Skip action in Install Execution Stage if executed in Dialogs Stage".

This way, you should be able to set the APPDIR property using the "Browse" button.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Feature Requests”