vicfees
Posts: 2
Joined: Tue May 19, 2009 4:56 pm

Set APPDIR to an existing environment variable

If a particular environment variable exists on the box, I'd like to set APPDIR to the value of this variable.

Is this possible? If so, how? Also, if this is in the documentation, could someone please point me to it.

Help is appreciated.

Vic
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Set APPDIR to an existing environment variable

Hi Vic,

To set environment variables you can use the Environment page. You can replace the value of an existing variable by setting the "Behavior" combo to "Replace" in the Edit Environment Variable dialog.

Please note that the modification can be seen only after the install is finished. This is because an environment variable cannot be accessed by the same process which creates it.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
vicfees
Posts: 2
Joined: Tue May 19, 2009 4:56 pm

Re: Set APPDIR to an existing environment variable

This is not an answer to my question, other than to say that it's not possible to set APPDIR to an existing environment variable.

And, there's no way to "search" for such a variable.

Wow, that is unfortunate.

Vic
rprussell
Posts: 38
Joined: Tue Feb 24, 2009 5:34 pm

Re: Set APPDIR to an existing environment variable

Why not write your own VB module and custom action to do so?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Set APPDIR to an existing environment variable

Hi Vic,

To set a new or existing variable you can create it in the "Environment" page. You can set its value to the installation path by using "[APPDIR]" in the "Value" field of the "Edit Environment Variable" dialog. Please note that in my previous post the underlined blue text has links to articles which explain how to manage environment variables.

In order to set the variable only if it exist, you can try this:
- make sure that the variable uses a custom component (for example you can use a registry entry which is created when the variable is updated)
- in the "Environment" page right-click the variable and select the "Go To Component" context menu
- condition the component of the variable with the environment variable you are setting

For example, if the variable is called MY_VAR, the condition can be:

Code: Select all

%MY_VAR
This way the component of the environment variable will be installed only if the variable is already set to something on the target machine.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
IanC
Posts: 5
Joined: Sun Feb 02, 2014 2:05 pm

Re: Set APPDIR to an existing environment variable

Is there a code sample, a .aip, that shows how to do this with [AppDir]? It would greatly help. :D
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Set APPDIR to an existing environment variable

Hello Ian and welcome to Advanced Installer forums,

Please correct me if I misunderstand your scenario.
If you want to set the APPDIR property with the value of an existing environment variable from the target machine, then you can go in the Custom Actions page and add the predefined Set installer property custom action with sequence.

You can edit the custom action properties like that:
  • Property: APPDIR
    Value: [%MY_ENVIRONMENT_VARIABLE]
Also, you should add in the Condition field of the custom action the %MY_ENVIRONMENT_VARIABLE statement in order to condition the execution of this custom action only if the related environment variable exist. Also, this custom action should be executed only on the Install process.

If you want to Add environment variables to your project, please take a look on this article with related information for hints and guidance.

Please let me know if that helped, otherwise give us more details about your specific scenario.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
IanC
Posts: 5
Joined: Sun Feb 02, 2014 2:05 pm

Re: Set APPDIR to an existing environment variable

Thanks for the help Dan! Rapid Response!

I'll take a look and post back here if I have any additional questions!

Return to “Common Problems”