Windows: Environment Variable Tutorial

By Xah Lee. Date: . Last updated: .

What is Environment Variable

Environment variables are system-wide global variables. They are config parameters and is used by processes. For example, apps need to know the path of your Windows kernal, path of your home dir, paths to search for shell programs, etc.

Case Sensitivity

Windows environment variable names are Case-Insensitive.

View Environment Variables

Launch the System Properties app

Press ❖ Window key, then type “environment”

or

press ❖ Windows+r then type sysdm.cpl

or

Type in shell

# launch the GUI app for environment variable
c:\Windows\System32\SystemPropertiesAdvanced.exe
win11 SystemPropertiesAdvanced 2025-12-21 192f3
win11 SystemPropertiesAdvanced 2025-12-21 192f3
win11 environment variable 2025-12-21 19269
win11 environment variable 2025-12-21 19269

Sample Values of Environment Variable

Here's example of env var values as it exists on my system.

Types of Environment Variable

There are 3 types of environment variable:

Process
  • Per session.
  • It is temporary.
  • It exist only for the current session in cmd.exe or PowerShell.
  • After you exit the shell, the variables you created are gone.
  • When a shell starts, it gets environment variable from the Windows Registry.
User
  • Permanent, stored in Windows Registry.
  • Per user.
  • Each user may have different values.
  • Examples: home folder HOMEPATH, temp dir (TEMP and or TMP).
  • In Registry, they are at: HKEY_CURRENT_USER\Environment.
Machine
  • Permanent, stored in Windows Registry. Per machine.
  • Each machine may have different values.

Examples:

  • OS kernal path (WINDIR)
  • processor info (PROCESSOR_ARCHITECTURE, NUMBER_OF_PROCESSORS, etc)
  • application paths (PATH)
  • executable file name extensions (PATHEXT)
  • OS type (OS)
  • current user name (USERNAME)

In Registry, they are at:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

Process environment variable is also known as Local Environment Variable.

User environment variable and Machine environment variable are together also known as System Environment Variable.

Note that you can set any new env vars in any category. Programs have access to all your env vars, but which ones are meaningful to the program is up to the program.

Show or Set Environment Variables using Powershell

Show or Set Environment Variables using cmd.exe

Microsoft Windows Environment Variable and Registry