How to Set Environment Variables and PATH in Windows 11 & 10

How to Set Environment Variables and PATH in Windows 11 & 10

An environment variable is a named setting – a label with a value – that programs can read. PATH is a special one: a list of folders where Windows looks for programs when you type a command. Developers, command-line tools, Java, Python and many installers rely on them.

In this guide you will learn three things in Windows 11 and Windows 10:

  • Method 1 – create a variable in the Environment Variables window,
  • Method 2 – add a folder to your PATH,
  • Method 3 – set a variable with one command (setx).

We use user variables: they only affect your account and do not need administrator rights.

Video: How to Set Environment Variables and PATH in Windows 11 & 10
▶ Prefer video? Watch this tutorial on our YouTube channel.

Method 1: Create a new environment variable

Step 1. Open Environment Variables

Click Start, type environment and choose Edit environment variables for your account. The Environment Variables window opens. The top list holds your User variables.

Environment Variables window with User variables in Windows 11
Environment Variables window – User variables at the top

Step 2. Click New and type a name

Under User variables, click New…. In Variable name type a name, for example DEMO_FOLDER.

New User Variable dialog – variable name
Variable name

Step 3. Type the value and click OK

In Variable value type the value, here the folder C:\Demo\Tools, and click OK.

New User Variable dialog – variable value
Variable value

Your new variable now appears in the list.

New environment variable in the User variables list
Your new variable

Method 2: Add a folder to PATH

Step 1. Edit the Path variable

In the same window, select Path under User variables and click Edit….

Edit button for the Path user variable
Select Path → Edit

Step 2. Click New

In the Edit environment variable window, click New. An empty line appears at the end of the list.

New button in Edit environment variable window
Click New

Step 3. Type the program folder

Type the folder that contains your program, e.g. C:\Demo\Tools, and press Enter.

Program folder added to PATH
Your program folder

Step 4. Click OK twice

Click OK, and OK again in the Environment Variables window to save everything.

OK button to save environment variables
OK again to save

Step 5. Test it in a new Command Prompt

Open a new Command Prompt and type the program name – here mytool.

Typing a program name in Command Prompt
Type the program name

It runs from any folder, because Windows finds it through PATH.

Program runs from any folder thanks to PATH
It runs from any folder

Method 3: Set a variable with one command (setx)

Step 1. Type setx NAME value

In Command Prompt type setx, then the name and the value:

setx DEMO_COLOR blue
setx command in Command Prompt
setx NAME value

Step 2. Press Enter

Windows confirms SUCCESS: Specified value was saved. – the variable is saved for good.

SUCCESS Specified value was saved
Saved for good

Step 3. Check it in a new window

Close the window, open a new Command Prompt and type:

echo %DEMO_COLOR%
echo environment variable in Command Prompt
echo %DEMO_COLOR%

It prints blue. New variables only show up in windows you open after the change.

Environment variable value printed in Command Prompt
It prints the value

PowerShell: read a variable with $env:DEMO_COLOR.

Tips and troubleshooting

  • Always open a new window after changing variables – old windows won’t see the change.
  • Never delete existing entries from PATH – only add new ones.
  • Don’t use setx to change PATH – it can cut long values (1024 characters).
  • System variables affect every user and need administrator rights (Start → Edit the system environment variables → Environment Variables).

Summary

  1. New variable: Start → “Edit environment variables for your account” → New → name + value → OK.
  2. PATH: select Path → Edit → New → folder → OK → OK.
  3. Command: setx NAME value, then open a new window.

Frequently Asked Questions

How do I open Environment Variables in Windows 11?

Click Start, type environment and choose Edit environment variables for your account (user variables) or Edit the system environment variables (system variables, needs admin rights).

What is the PATH variable?

PATH is a list of folders where Windows looks for programs when you type a command. If a program’s folder is in PATH, you can run it from any folder.

Why doesn't my new variable work in Command Prompt?

Windows that were already open do not see the change. Close Command Prompt (or your app) and open a new one.

Should I use setx to change PATH?

No. setx cuts values longer than 1024 characters, which can damage a long PATH. Edit PATH in the Environment Variables window instead.

What is the difference between user and system variables?

User variables affect only your account and need no admin rights. System variables affect every user on the PC and require administrator rights.