Abbas
Posts: 15
Joined: Fri Dec 06, 2013 6:21 am

Environment Variables

Hi Team

I have added a "Launch File" in the Custom Actions section to launch a batch file which refers to an Environment Variable that I have defined in the Environment Variables section. Let's say the variable is HOME=[APPDIR], and the batch file has a command like cd %HOME%. It looks like the environment variables are not known in that stage because they are not created until the installation process is finished. What should I do to get around this problem?

The above is a general problem regardless of the windows platform. I have another problem which is specific to Windows Server 2008. I have created a simple Advanced Installer project, all which does is defining an environment variable. It works fine if I run the installer on Windows 8; but if I run it on Windows Server 2008, there is no environment variables defined after the installation is finished successfully. Am I missing something here?
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Environment Variables

Hello and welcome to Advanced Installer forums,
I have added a "Launch File" in the Custom Actions section to launch a batch file which refers to an Environment Variable that I have defined in the Environment Variables section. Let's say the variable is HOME=[APPDIR], and the batch file has a command like cd %HOME%. It looks like the environment variables are not known in that stage because they are not created until the installation process is finished. What should I do to get around this problem?
Please note that modifications to the environment variables do not result in immediate change, so in order to have the newly updated path you can have a custom action that will force a refresh of the environment variables. Basically you need to broadcast a settings change message to all windows in the system so that any interested application can perform an update.

You can also take a look on How to propagate environment variables to the system article.
I have another problem which is specific to Windows Server 2008. I have created a simple Advanced Installer project, all which does is defining an environment variable. It works fine if I run the installer on Windows 8; but if I run it on Windows Server 2008, there is no environment variables defined after the installation is finished successfully. Am I missing something here?
I'm not sure why you encountered this behavior. I've tested your scenario on a Windows Server 2008 x64 machine and I could successfully create an environment variable. So, can you please create a verbose log of the installation process and send us to support at advancedinstaller dot com so we can investigate it?

Please let us know if that helped, otherwise give us more details.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Abbas
Posts: 15
Joined: Fri Dec 06, 2013 6:21 am

Re: Environment Variables

Hi Dan,

Thank you for your response. With regard to the first problem, I had a look at the article you suggested (http://support.microsoft.com/kb/104011/en-us) to see if I can force a refresh of the environment variables, but I could not figure out how to define a custom action to refresh variables in the installer project. Would it be possible for you to send me an example proj which does this?

Regarding the second problem, I created a simple Installer to define ABHOME=[APPDIR] as an environment variable, and tried it on Win2003, Win2008, Win2012. Although the installation process finishes successfully on all platforms, it does not create the environment variables on Win2003 and Win2008. It works fine only on Win2012. I have attached a zip file which contains the installer project as well as win2003.log, win2008.log, and win2012.log.

Kind regards,
Abbas
Attachments
Inst Proj Logs.zip
A zip file containing:
- Installer project
- Log files
(667.55 KiB) Downloaded 382 times
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Environment Variables

Hello Abbas,
I could not figure out how to define a custom action to refresh variables in the installer project. Would it be possible for you to send me an example proj which does this?
Unfortunately, we don't have any samples regarding this scenario.
Regarding the second problem, I created a simple Installer to define ABHOME=[APPDIR] as an environment variable, and tried it on Win2003, Win2008, Win2012. Although the installation process finishes successfully on all platforms, it does not create the environment variables on Win2003 and Win2008. It works fine only on Win2012. I have attached a zip file which contains the installer project as well as win2003.log, win2008.log, and win2012.log.
I've tested your scenario and I successfully created an environment variable on Windows Server 2003 x86 and Windows Server 2008 x64. Can you please test on another clean machine and see if the behavior still persist?
Also, from the attached logs, you should have, at least, the ABHOME environment variable created.

Code: Select all

MSI (s) (4C:68) [11:26:00:272]: Executing op: UpdateEnvironmentStrings(Name=ABHOME,Value=C:\Program Files\TestingComp\EnvironmentVarTest\A\,Delimiter=[~],Action=1,)
WriteEnvironmentStrings: Name: ABHOME, Value: C:\Program Files\TestingComp\EnvironmentVarTest\A\, Action 1
You can use the set command in the CLI to see your windows environment variables.

Also, can you please tell us after which standard action have you scheduled your launch file predefined custom action? Is this custom action set as deferred?

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
hadas
Posts: 43
Joined: Mon Jan 06, 2014 10:53 am

Re: Environment Variables

Hi,

I have been reading few posts regarding System Environment Vars. Can you please clear up what will be the beast practice to make sure System Vars are available during the installation (I have bat files that need to use the vars).
I'm using Win 7.

Thanks,
Hadas
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Environment Variables

Hi Hadas,

It seems that modifications to the environment variables do not result in immediate change, so you do not have access to the newly created environment variables until the machine is rebooted.
Here are some threads which debate this issue:
- System environment variable created during install not available to current user until reboot
- How do you add a Windows environment variable without rebooting?

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: Environment Variables

Hmmm... I too am looking for a way to force a refresh of the environment variables and I'm not having success. Any Pointers?
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Environment Variables

Hello Ian,

As you can see, there is not so easy as it looks like to force a refresh of the environment variables. The easiest and safer way is through a reboot.
So, can you please give us more details about your scenario?

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”