How do you add a Windows environment variable without rebooting?

Solution 1:

Changes to environment variables should take effect immediately, if you make the change via the main Properties dialog for the computer in question (go to My Computer | Properties | Advanced | Environment Variables). After the changes are saved, Explorer broadcasts a WM_SETTINGCHANGE message to all windows to inform them of the change. Any programs spawned via Explorer after this should get the updated environment, although already-running programs will not, unless they handle the setting change message.

I'm not able to tell from your problem description what specific problem you're having with this. Can you tell us more about the specific scenario that isn't working?

This KB article may also be of use: How to propagate environment variables to the system

Solution 2:

  1. In a command prompt type: runas /user:yourusername@yourdomain cmd
  2. It will open up a new cmd prompt, then type: taskkill /f /im explorer.exe
  3. Then type: explorer.exe

Now after closing all command prompts, you will see that the PATH variable has been truly updated.

All command prompts must be closed. Reopen a new command prompt, type path and you will see the new data.

Solution 3:

One thing to keep in mind is that many programs obtain the environmental variables when they're first started, so while windows may not need a restart, some programs might before they'll be able to use the new variables. Good example of this is having to open a new command prompt window after adding a PATH (yes, I've been tripped up by this).

Solution 4:

Whilst I don't have enough of a reputation to comment on the highest voted answer to this question, I would like to state that it is not exactly correct. I know this because no matter which workaround I tried in this post, nothing actually worked.

The kb article linked to in that answer actually states that:

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.

The part about the environment variables resetting to the previous values after reloading the command prompt is exactly what I experienced in Windows Server 2008.

The article goes on to say:

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.

That does not imply that Explorer broadcasts a WM_SETTINGCHANGE message once you have changed the system environment variables, or that it actually works. I'm not sure how you would do what is suggested in the KB article (to propagate the changes immediately) from the command prompt.

Solution 5:

Make the env. variable available straight away:

1. Open a shell

Depending on the environment variable you want to change do the following: (supose that you want to add a new PATH for a recently installed application) So, at the shell prompt, type the following:

2. PATH=%PATH%;C:\type\your\new\path\here

check that your new path has been added to the environment variable

3. echo %PATH%


Make the variable available on reboot

1. Press WinLogoKey+Pause/Break
2. On the left pane, press 'Advanced System Settings'
3. On the 'Advanced' tab, click 'Environment Variables'
4. In 'System Variables' choose the one you want to modify
5. Click Ok

Tested and working on Windows 7/10