cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
khansen
Level 5

Setting and using environment variables

During the install phase I create a couple of environment variables using the "Set System Environment Variable" action. I run some executables and scripts during the install process that rely on those variables, however, they don't seem to be set. I tried using the RefreshEnvironment plug-in, but it doesn't seem to work either. After installation, I can see that the environment variables are set under System Properties but not when I open a new command prompt and type "set". Is it possible to refresh the environment so that these variables are usable without having to restart the system?
Labels (1)
0 Kudos
(8) Replies
james_decosta
Level 9

hi,
even i have the same requirement,from where did you find the refresh environment plugiin.
I am trying to set a system environment variable to a installanywhere variable and use the system environment variable in my batch file .
how do i do it
0 Kudos
khansen
Level 5

The RefreshEnvironment plug-in is an InstallAnywhere action. It is listed under the Plug-Ins tab when you choose Add Action. The description for the plug-in reads, "This action will force the Windows operating system to refresh its environment. This is helpful right after a Set Environment Variable action." As mentioned, this didn't appear to work for me.

I had to take a less than optimal approach to work around this issue. I am using the Execute Script/Batch file action and setting the environment variables at the top and then copying the contents of the batch file below. The problem with this, is that I need to maintain both the batch file and the code in the installer. For everything else that relies on the environment variable after installation, it looks like I'll just have to restart Windows.

Another option I considered was to use the Modify Text File action and explicitly set the environment variables in the batch files. Then I could run either Execute Command or Execute Target File on the batch file. Unfortunately there are more than just a couple of batch files that rely on this environment variable.
0 Kudos
jerry924
Level 2

Has anyone resolved this issue? I am having the same issue. I set a system environment variable, call RefreshEnvironment plug-in, and then execute custom code which is a java method to print out System.getenv() and my new variable setting did not get applied. I confirmed that I am seeing other environment variables such as PATH, its just the environment variable I set with IA is not actually getting applied.

There are no warnings or errors in the debug console (holding CTRL down while installer running). There is however a message printed "Calling Refresh Environment"
0 Kudos
james_decosta
Level 9

hi jerry,
i am trying to fix this issue using java native interface.
If you can just contribute to this issue help me out in solving this refreshing problem.
james.
0 Kudos
james_decosta
Level 9

hi,
you need to proceed as this:
Inside it you will get a refresh.dll file we need to install it in windir that is in C:\WINDOWS in case of windows xp and in C:\WINNT in case of windows 2000
in the first place then we need to add execute custom code action tab
and then add the refreshenvironment.jar and give the classname as RefreshEnvironment ,just check once and revert back for any clarifications.
james.
0 Kudos
AnnaGR
Level 3

Hello,

I've got the same problem with the environment variable. The plugin RefreshEnvironment works properly under Windows - Vista but not XP. I've replaced this plugin with the custom code action you described, but it didn't change anything. I get the same error as by plugin:
class RefreshEnvironment NonfatalInstallException :
....\Temp\I1209872707\Windows\refresh.dll
0x80070020 The process cannot access the file because it is being used by another process.

Did you find the solution till now? Thank you for any advice

Anna
0 Kudos
asr105
Level 3

We face the same problem too. The system needs a restart for the env variables to be active.

Thus, we not only set the variables via the installer but also place scripts in the temp folder & run it, in case the env variables are needed by the installer itself. (The scripts basically set the env variables)
0 Kudos
janosh
Level 3

Hello,

something about the reason for our problems:
IA tries to propagate changes on environment variables with the RefreshEnvironment plugin. (See WM_SETTINGCHANGE message on http://support.microsoft.com/kb/104011/en-us) On Unix shells this is simply the export command. The first message in this thread matches my results without the plugin.

For me the RefreshEnvironment plugin is working with IA2008 VP1 as a post installation action.
But you must not call it twice. Otherwise the refresh.dll will be in use. It seems like it is called somewhere at the end of the installer.

The plugin still does not work on uninstallations (bug #IOC-000053634) and there seems to be no date for a resolution.

Calling an msi-Installer seems to be a workaround. Has anyone succeeded with a custom action?
0 Kudos