views:

675

answers:

5

Hi, I added a custom install action to my installer to add one of my installation directories to the System PATH environment variable. After I run the installer, the PATH variable reflects the changes (when I access it through the Control Panel::System applet), but when I start a new command shell, the PATH variable does not reflect the changes. Is there something I'm failing to do, that causes this?

+2  A: 

How are you starting the command shell? With the TaskManager?

I suspect you might be starting it from Explorer - if I remember correctly, this could meen that you are inheriting the parent processes (Windows Explorer in this case) PATH variable. Since that was set before your installer ran, you see the old value.

Not sure if this helps...

Daren Thomas
+1  A: 

I think this depends on how you are starting the new Command shell. For example, when you change the PATH environment variable under System properties, the change isn't reflected until you open a new Command prompt. I think when you launch a new "cmd" process (from the Run dialog for example), you get a fresh copy of all environment variables, but if you launch the command prompt a different way then you do not.

For something done thru a script like that, you may need to restart before you notice the change.

matt b
+1  A: 

http://support.microsoft.com/kb/310519 says that for system environment variables (which PATH is one of) requires a restart, although I have a feeling that logging off and on may be enough.

Celestial M Weasel
A: 

How are you adding the environment variable?

Without using any external tools, you can add it to the registry. Then, your test of opening a new command window will reflect your change.

spoulson
+1  A: 

Why are you using a CustomAction for this? The Windows Installer supports modifying environment variables natively. Also, I think the Windows Installer sends a broadcast message to update the system when environment variables change. That may mean you don't need to reboot... but it's been a while since I tried so YMMV.

Rob Mensching