Pcornel
Browse topics
Options
Recent
Favorites
Windows · Technical reference

Environment Variables · Windows Fundamentals

Direct answer

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.

When to use this

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.

First 30 seconds

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.

Operational verification

machine and user variables → merged at logon/process start → inherited by child processes → read by the program

Evidence · next step

Verify application consumption and the resource/path represented by the value.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Common mistakes
Persistent change is not live process mutation

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.

Platform / version applicability
Microsoft Windows
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformMicrosoft Windows
Scope / prerequisiteUse it when a script, service or application sees a different path, temporary directory, profile location, token/endpoi…
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

1 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Key points
  • 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:NAME for process-environment access.
  • Machine/User persistent environment settings are backed by Registry locations, but applications consume process state.
Key checks
  • Get-ChildItem Env: — environment of the current process
  • [Environment]::GetEnvironmentVariable('<Name>','Machine') — machine-level value
  • [Environment]::GetEnvironmentVariable('<Name>','User') — user-level value
  • setx <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.

VariableTypical 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docMicrosoft Windows current

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%
Terminology layer

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.

Aliases that resolve here
windows env varsenvironment variables windowsprocess user machine environment$envsetx environment
Embedded reference data

Quick lookup tables

Environment-variable scopes

Persistence and visibility depend on scope and process lifetime.

ScopeLifetime / persistenceTypical verification
Processcurrent process lifetimeread from the exact shell/process
Userpersistent for one user; seeds future processescompare User config with a newly started process
Machinepersistent system-wide; seeds future processescompare Machine config with newly started user/service processes
Child processinherits a copy from parent unless overriddenidentify parent and creation time
Confirmation

Confirm action

Continue?