Use it when a script, service or application sees a different path, temporary directory, profile location, token/endpoint setting or other variable than the value configured elsewhere.
Environment Variables · Windows Fundamentals
Environment variables are name/value pairs exposed through a process environment block. Windows commonly distinguishes Process, User and Machine scopes. A new process normally inherits a copy of its parent’s environment, while persistent User/Machine values seed future process environments.
1. $env:<Name> in the failing context — set?
2. Machine vs User scope — which holds it?
3. Set persistently: setx or System Properties; new processes only see it.
4. Services read machine variables at service start — restart the service.
5. Verify in the process: Process Explorer → Environment tab.
machine and user variables → merged at logon/process start → inherited by child processes → read by the program
Verify application consumption and the resource/path represented by the value.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Editing Environment Variables in System Properties or changing a persistent value through an API/command does not teleport that value into every process already running. A shell, IDE, service host or management agent can continue with its old inherited environment until it or its parent context is recreated.
Operational checks for Environment Variables — Persistent change is not live process mutation: Anchor the same process/service/object, security context and effective runtime state; registry or GUI configuration alone is not closure.
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Diagnose a stale environment value Verify boundary
1. Capture the value inside the failing process or its launching shell.
2. Capture the intended User and Machine values.
3. Identify when and by which parent process the consumer was started.
4. Launch a new process after the change and compare.
5. For services, restart only the service/process that must rebuild its environment, then verify behavior.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- A process owns its current environment block. Changing a persistent variable does not rewrite every existing process.
- User and Machine variables persist; Process-scope changes disappear with that process unless explicitly persisted elsewhere.
- Child processes normally inherit a copy of the parent environment at creation time.
%NAME%is common cmd expansion; PowerShell uses$env:NAMEfor process-environment access.- Machine/User persistent environment settings are backed by Registry locations, but applications consume process state.
Get-ChildItem Env:— environment of the current process[Environment]::GetEnvironmentVariable('<Name>','Machine')— machine-level value[Environment]::GetEnvironmentVariable('<Name>','User')— user-level valuesetx <Name> <Value>— persist for the user (new processes)
ReferenceWhat it is1 section · depth on demand
Environment blocks are process state
Windows exposes environment variables to a process through an environment block containing name/value pairs. When a process creates a child process, the child normally receives a copy of an environment assembled from its parent context. This explains why two shells opened at different times can show different values even though they belong to the same user on the same computer.
ReferenceWhy it matters1 section · depth on demand
Internals and state
Topic-specific scope
Local intent: Windows environment-variable scopes, inheritance and persistence: Process, User and Machine state, including why running processes can retain stale values after a change.
ReferenceImportant terms & boundaries2 sections · depth on demand
Process, User and Machine scope
- Process: changes affect the current process environment and descendants created from it; they are not inherently persistent.
- User: persistent values associated with one user and used when building future environments for that user.
- Machine: persistent computer-wide values used as a base for future processes.
Persistent User/Machine settings are stored in Windows configuration/Registry locations, but a running application reads the process environment it currently owns.
In depth
Environment variables are named values that processes inherit, used for paths, user and system information and configuration. Windows keeps system-wide variables (for all users), user variables, and process-level variables set at run time.
| Variable | Typical value |
|---|---|
%SystemRoot% | C:\Windows |
%ProgramFiles% | C:\Program Files |
%USERPROFILE% | C:\Users\name |
%TEMP% | User temp folder |
%COMPUTERNAME%, %USERNAME% | Identity |
%PATH% | Executable search path |
Get-ChildItem Env:
[Environment]::SetEnvironmentVariable('TOOLS_HOME','C:\Tools','Machine') # persistent, system
$env:TOOLS_HOME = 'C:\Tools' # current session only
Running processes do not see changes made after they started — restart the application or log off. Never store secrets in persistent environment variables visible to all processes.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Windows Fundamentals → Environment Variables. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://learn.microsoft.com/en-us/windows/ · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Environment-variable scopes
Persistence and visibility depend on scope and process lifetime.
| Scope | Lifetime / persistence | Typical verification |
|---|---|---|
| Process | current process lifetime | read from the exact shell/process |
| User | persistent for one user; seeds future processes | compare User config with a newly started process |
| Machine | persistent system-wide; seeds future processes | compare Machine config with newly started user/service processes |
| Child process | inherits a copy from parent unless overridden | identify parent and creation time |