Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Suppose I go into the System Properties window and add an environment variable to the Path. If I have a terminal window open, it will be unaware of the change, so I close it and open another one.

Is there a way to have it reload the Path information from the command line? I'd particularly like to know how I can do it with my Cygwin shell, but I'd be happy to know how to handle either case (Cygwin or native terminal).

share|improve this question
add comment

2 Answers

There is not built-in method for changes to be propagated to child processes automatically, processes can be setup to listen for a particular message, and update, but for that requires special handling within the application.

Propgation of the environment to some applications is the exception rather then the rule. The normal behavior is that when process is created it gets a copy of the environment from the parent process. Changes with to the environment within that process do not propagate back to the parent. After a process has been created any further changes in the environment of the parent do not get propagated to the child.

On Windows the environment the system variables that you set through that interface are stored in the registry, so you could theoretically write a script in cygwin that would re-read the registry and output the current variables, and then use that to update the environment in the current shell.

From the kb http://support.microsoft.com/kb/104011

However, note that modifications to the environment variables do not result in immediate change. For example, if you start another Command Prompt after making the changes, the environment variables will reflect the previous (not the current) values. The changes do not take effect until you log off and then log back on.

To effect these changes without having to log off, broadcast a WM_SETTINGCHANGE message to all windows in the system, so that any interested applications (such as Windows Explorer, Program Manager, Task Manager, Control Panel, and so forth) can perform an update.

share|improve this answer
add comment

Well in a windows console, just type cmd and hit enter. This technically puts you in a new session inside your other session, but it will have the new env variables. What it won't have is session information from the outer session. So any env variables or command history, that sort of thing.

share|improve this answer
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.