Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installer changes PATH variable, changes don't show up in Command Shell

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?

like image 491
Brian Stewart Avatar asked Sep 02 '08 19:09

Brian Stewart


People also ask

How do I force an environment variable to update?

Use "setx" and restart cmd prompt It's for reading and writing env variables. The variables persist after the command window has been closed. It "Creates or modifies environment variables in the user or system environment, without requiring programming or scripting.


2 Answers

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.

like image 180
matt b Avatar answered Dec 15 '22 04:12

matt b


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...

like image 45
Daren Thomas Avatar answered Dec 15 '22 03:12

Daren Thomas