Windows

Where Are Windows Environment Variables Stored?

Windows keeps user variables in HKCU and system variables in HKLM. Registry paths, precedence, and editing rules.

Last updated

Windows stores environment variables in the registry, not in files. Per-user variables live under HKEY_CURRENT_USER\Environment; system-wide variables live under the Session Manager key in HKEY_LOCAL_MACHINE. The Settings app and setx edit these keys behind friendly dialogs.

Two rules prevent most confusion. System and user PATH concatenate rather than override, with system first, which explains mystery tool versions. And no running process picks up changes until it restarts, which explains edits that seemingly do nothing. Edit through the UI or PowerShell rather than regedit; a typo in the system key affects every process on the machine.

Where Windows environment stores this, by platform

Windows
HKCU\Environment

User variables in HKCU\Environment; system variables in HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment. System PATH prepends user PATH on merge. Changes need new processes to take effect. Prefer Settings, setx or PowerShell over raw regedit; back up the values before bulk edits.

Frequently asked questions

which wins user or system path

System variables win on collision, and PATH concatenates instead of overriding: the process sees system PATH followed by user PATH. That is why java -version can report a version you never put in your user PATH. Inspect the merged result with echo %PATH% in a fresh terminal, not by reading one hive.

why do new env vars not work in my terminal

Open a new terminal. Environment changes apply to processes started after the edit; already-open shells, editors and build tools keep the old values. Broadcasting exists but plenty of apps ignore it. When in doubt, log out and back in rather than debugging a stale shell.

how do i set env vars from command line

Yes, with a reboot-free method: setx writes to the user hive (HKCU\Environment) from a script, and [Environment]::SetEnvironmentVariable with the Machine target covers system. Both need a fresh process to take effect. setx truncates PATH at 1024 characters, so prefer PowerShell for PATH edits.

Notice an outdated path? Let us know.