Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
    
Hm, well the problem we're actually experiencing doesn't have to do with a process that is already running. If she runs our application, by opening a new command shell after changing the environment variable and typing the application command (e.g. app.exe, which is in %APP_HOME%bin) it uses the one from the old directory (e.g. 7.0). So, it doesn't seem like we have any old processes that haven't been restarted... –  jwir3 Feb 9 '11 at 17:48
    
@jwir3 How is she setting the new value of APP_HOME? Via cmd line or through system settings? –  squillman Feb 9 '11 at 17:49
    
@squillman: Through system settings - Control Panel->System->Advanced->Environment Variables. –  jwir3 Feb 9 '11 at 17:57
1  
Also, I forgot to mention - it actually resets back to the 7.0 version if she logs out and logs back on. So, something really strange seems to be going on here. –  jwir3 Feb 9 '11 at 17:58
1  
@jwir3 ok, then It's as I was saying. By "editing" the PATH variable you're forcing Windows to refresht it. Windows will reread your APP_HOME value and incorporate it into the new value for PATH. Just resetting APP_HOME doesn't force a refresh of other variables that rely on it. –  squillman Feb 9 '11 at 18:14
show 5 more comments

This seems to be an IIS bug. A restart will fix your problem. Note that killing w3wp and recycling the app pool will not do anything.

You can check to make sure w3wp uses the correct environment path via processexplorer.exe

share|improve this answer
    
I think this is not IIS bug. Environment variables are "inherited" from parent process and w3wp.exe is hosted by svchost.exe which "knows" nothing about changes. –  Eugene Nov 26 '13 at 6:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.