Caching of path environment variable on windows

environment-variableswindows-xp

I'm assisting one of our testers in troubleshooting a configuration problem on a Windows XP SP3 system. Our application uses an environment variable, called APP_HOME, to refer to the directory where our application is installed. When the application is installed, we utilize the following environment variables:

APP_HOME = C:\application\
PATH = %PATH%;%APP_HOME%bin

Now, the problem comes in that she's working with multiple versions of the same application. So, in order to switch between version 7.0 and 8.1, for example, she might use:

APP_HOME = C:\application_7.0\ (for 7.0)

and then change it to:

APP_HOME = C:\application_8.1\ (for 8.1)

The problem is that once this change is made, the PATH environment variable apparently still is looking at the old expansion of the APP_HOME variable. So, for example, after she has changed APP_HOME, PATH still refers to the 7.0 bin directory.

Any thoughts on why this might be happening? It looks to me like the PATH variable is caching the expansion of the APP_HOME environment variable. Is there any way to turn this behavior off?

Best Answer

The changes are not dynamic. When you change environment variables for Windows then other processes need to be restarted in order for them to operate in the new environment.

When a process starts it'll expand the value of your APP_HOME variable and append it to your PATH. You'll need to restart the process to reinitialize, or reset the PATH variable so it reads the new value of APP_HOME.