Reputation: 2948
I am building an installer for a piece of software that requires a third-party executable to be in the path in order to run. In other words, my software calls 3rdparty.exe
with a system call.
I ran the 3rd party installer and then ran my software, but my software did not find 3rdparty.exe
because the path environment variable hadn't been changed. I confirmed this by running set > file.txt
at a brand new command line and the new addition to the path was not there. Yes, I started the new command line after the 3rd party software completed--minutes after.... so yes, the environment variables should have been populated.
Now here's the weird part. I went to the "Environment Variables" dialog box to edit the System path, and guess what, the new path was already there, tacked on to the end of the old one.
So here's the facts I'm left with:
The third-party installer makes a change to the System path
environment variable, adding C:\program files\blah\...
to the end of
the path.
This shows up immediately in "Environment Variables" dialog box.
This did not show up without a reboot in any new cmd.exe shell I started. Yes, I tried it multiple times.
I have never seen this behavior before. Can someone please explain what is going on here? I have operated for years under the presumption that once the environment variable has been set, any new process would get a copy of the full, current environment. This didn't happen in one case.
When are Windows environment variable changes applied? What am I missing? Is this an artifact of some weird installer for the 3rd party software? Is this an artifact of Windows being flaky?
To boil it all down to one question: what happened?
Upvotes: 0
Views: 1762
Reputation: 30258
Changes made using the SET
command are NOT permanent, they apply to the current CMD prompt
only and remain only until the CMD
window is closed.
To permanently change a variable at the command line use SetX
or with the GUI - Control Panel | System | Environment | System/User Variables
cf. SETX.exe (Resource Kit, Windows 7)
Updated: though we don't know the way the 3rd party installer changes the system path environment variable, all symptoms indicate doing it by registry change - and if does not broadcast a WM_SETTINGCHANGE
message, then, according to Microsoft Technet and MSDN pages, changes do not take effect until you log off and then log back on - or even restart the computer... (through, or due to, caching of some registry data).
The behavior described in your question does not seem to be weird: it's not an error, it's a feature... :-)
Upvotes: 1