How to Set Up Environment Variables in Windows 11
- 19 steps
- Needs administrator rights
- Includes a restart or sign-out
An environment variable in Windows 11 is a named text value that tells programs where to find folders, files and system settings on your PC. To open the settings, right-click Start, choose System, click Advanced system settings, then click Environment Variables… on the Advanced tab.
Adding or changing environment variables lets custom tools, programming languages and batch scripts (text files of commands that run in order) work properly. Windows relies on built-in variables to know where its own folders live, so apps don’t have to guess a path like 📁C:\
The Environment Variables window sits inside System Properties, the classic Windows screen that holds these environment properties. Adding a single variable takes less than one minute. Command Prompt and PowerShell can do the same job if you prefer a terminal.
To set environment variables in Windows 11, right-click Start, choose System, click Advanced system settings, then click Environment Variables… on the Advanced tab. Under User variables, click New to add a variable for your account only. Your change applies to programs you open after you save it.
What Are Environment Variables?
An environment variable is a name paired with a value. Windows and your programs look up the name and use the value, so nobody has to type a long path or setting each time. Windows keeps these values and hands them to every program you start.
Say you want a script to always know where your working folder is. You can store that folder in a variable called MY_FOLDER, and the script asks for MY_FOLDER and gets the path. If you move the folder later, you change the variable once instead of editing every script.
Some Windows environment variables exist from the start. Path is the best known: it is a list of folders Windows searches when you type a program name in a terminal. Many installers for programming languages and developer tools add their own folder to it. Variable names are not case-sensitive, so My_Folder and MY_FOLDER are the same name.
Variables come in two scopes. A user variable applies only to your account, so user environment variables never affect anyone else who signs in to the PC. A system variable applies to every account on the PC and needs administrator rights to change.
Programs read their variables when they start. That is why a change you make later does not reach a program that is already open.
Ways to Set Environment Variables in 🪟 Windows 11
There are three ways to create environment variables:
- System Properties – a graphical Windows screen with buttons and text boxes. It is the friendliest option and the best place to start.
- Command Prompt – a text-based tool where you type commands. It suits quick changes and batch files.
- PowerShell – a more advanced command tool, well suited to scripts and automation.
All three change the same stored values. A variable created in one place shows up in the others, so pick whichever you are most comfortable with.
1Using System Properties (Easy Way)
The built-in System Properties window lets you set environment variables in Windows 11 without touching any command-line tools. It is a safe way to add, edit, or delete user and system variables, so your apps can find the files they need without long typed paths. It works the same on Windows 11 Home and Pro.
The steps below open the environment variables settings, then add a new variable to your user account or to the whole PC.
- Right-click the Start button. A menu of system shortcuts opens above the taskbar.
- Select System from the menu. The Settings app opens on System About.
- Click Advanced system settings under the related links on the right side. Windows may ask for administrator approval. If it does, click Yes. The System Properties window then opens.

System Properties opens on the Advanced tab. If you land on another tab, click Advanced at the top.
- Click the Environment Variables… button near the bottom of the window. A new window opens with your environment variables settings.

Two lists now appear:
- User variables – These only affect your user account. Windows lists your user environment variables here, and the list title includes your account name.
- System variables – These affect all users on the computer.
If the buttons under System variables are greyed out or the change won’t save, you are signed in with a standard account. Use the User variables list instead, or sign in with an administrator account.
To add a new variable, follow these steps:
- Click New… under the list you want, User or System. ⚠️ Admin privileges required for System variables. A small dialog opens with two boxes.
- Type a name in the Variable name box. Use something like MY_FOLDER.
- Type the value in the Variable value box. An example is 📁C:\
Users\ . If the value is a folder, you can click Browse Directory… and pick it instead, which avoids typos.UserName\ Documents - Click OK to save the variable. The new variable now appears in the list.

- Click OK in the Environment Variables window. This saves the change and returns you to System Properties.
- Click OK in System Properties. Both windows close. If you close them with the X instead, your changes are lost.
That’s it. Your new variable is now stored in Windows, either for your account only or for every user, depending on the list you chose.
Programs that are already open won’t see the change. Close and reopen them, or log out and back in. Restart your computer if a program still doesn’t pick up the new value.
2Using Command Prompt
Command Prompt can set environment variables in Windows 11 with the setx command. It writes permanent values to your user profile or to the whole system, using typed commands instead of menus. A user variable doesn’t strictly need administrator rights, but the system-wide option does, so the safest habit is to open an administrator window from the start.
The steps below open an administrator Command Prompt and set a user variable, then a system-wide one.
- Right-click the Start button and select Windows Terminal (Admin). On some builds the entry is labeled Terminal (Admin). ⚠️ Admin privileges required.
- Click Yes if the User Account Control prompt appears. A terminal window opens, usually on a PowerShell tab.
- Click the down arrow next to the “+” tab and choose Command Prompt. A new tab opens with a Command Prompt.
- Type this command to create a user variable, then press Enter:Command Prompt
setx VARIABLE_NAME "VARIABLE_VALUE"
Replace VARIABLE_NAME with your variable’s name and VARIABLE_VALUE with the value you want. If the value contains spaces, keep it inside quotation marks. A message saying the value was saved means it worked.
Example:
setx Downloads "C:\Users\UserName\Downloads"- Type this command to create a system-wide variable for all users, then press Enter:Command Prompt
setx /M VARIABLE_NAME "VARIABLE_VALUE"
⚠️ Admin privileges required for /M flag. Without administrator rights, the command fails with an access error.
Example:
setx /M Downloads "C:\Users\UserName\Downloads"That’s it. The variable is now saved permanently, as a user variable or a system variable depending on which command you used.
The setx command does not change the window you typed it in. Open a new Command Prompt window to use the new variable. Restart your computer, or at least the program in question, if some programs still don’t see the change.
3Using Windows PowerShell
PowerShell can set environment variables in Windows 11 when you run commands in a terminal. This approach suits scripts and lets you view, create, or update variables directly. As with Command Prompt, a user variable doesn’t strictly need administrator rights, but the Machine scope (the setting that applies to the whole PC) does.
The steps below set a user variable first, then a system-wide one, from a PowerShell tab.
- Open Windows Terminal (Admin) as shown above. ⚠️ Admin privileges required.
- Check that you are in a PowerShell tab. It opens by default, and the tab title should say Windows PowerShell or PowerShell.
- Type this command to create a user variable, then press Enter:Code
[Environment]::SetEnvironmentVariable("VARIABLE_NAME", "VARIABLE_VALUE", "User")
Example:
[Environment]::SetEnvironmentVariable("Downloads","C:\Users\UserName\Downloads","User")- Type this command to create a system-wide variable, then press Enter:Code
[Environment]::SetEnvironmentVariable("VARIABLE_NAME", "VARIABLE_VALUE", "Machine")
⚠️ Admin privileges required for Machine scope. The Machine scope applies to every user on the PC.
Example:
[Environment]::SetEnvironmentVariable("Downloads","C:\Users\UserName\Downloads","Machine")That’s it. PowerShell has now stored the variable permanently, and you can use it in any window you open from here on.
New PowerShell or Command Prompt windows will see the change. Windows that were already open may not. Restart those programs, or your computer, to fully apply it.
How to Check if Your Variable Was Created
Check that your variable works from a new window opened after you made the change:
- In Command Prompt: Type
echo %VARIABLE_NAME%and press Enter. - In PowerShell: Type
$env:VARIABLE_NAMEand press Enter.
If everything worked, you should see the value you set. If you see nothing, or Command Prompt prints the variable name back with percent signs, the variable isn’t visible to that window. Close it, open a new one, and try again.
To fix environment variables that still fail in Windows 11, open the Environment Variables window and compare the name with what you typed. A typo in the name is the most common cause. Select the variable and click Edit… to correct the name or value, then click OK in both windows and test again from a new window.
Summary
- Environment variables help your computer and programs know important settings. Why? Because programs need to find files and folders quickly without having long file paths typed in every time.
- You can create them through Windows settings, Command Prompt, or PowerShell. What happens? Your computer remembers the setting and uses it when programs ask for it.
- User variables affect only your account, while system variables affect everyone and need administrator rights.
- Remember to restart your programs, or log out and back in, after creating new variables. Restart your computer if a program still doesn’t see the change. Why? Because programs read environment variables when they start up.
- Check your variables by echoing them in Command Prompt or PowerShell. What happens? The value displays on your screen so you can confirm it was set correctly.
Environment variables in Windows 11 are system values that help your computer and installed programs find files and folders quickly without long file paths typed out every time. You can manage these settings through the graphical System Properties window, Command Prompt, or PowerShell, depending on what you prefer.
Frequently asked questions
How to fix environment variables in 🪟 Windows 11?
To fix a wrong environment variable, open Environment Variables from System Properties. Select the variable under User variables or System variables, then click Edit to correct its value or Delete to remove it. Click OK in each window, then restart any open programs so they read the change.
How to add environment variable in 🪟 Windows 11?
Open Environment Variables by right-clicking Start, choosing System, clicking Advanced system settings, and then clicking Environment Variables. Under User variables, click New, type a name and a value, and click OK in each window. Restart any programs that were open so they pick up the new variable.
How to set environment variable in Windows?
Open Command Prompt and type setx MY_FOLDER "📁C:\
How to add environment variable in 🪟 Windows 11 sticky?
Add the variable under User variables in Environment Variables, then click OK. Windows saves it permanently, so it stays in place after you restart your PC. It also remains after you sign out and back in. To remove it later, return to the same window and click Del.
How to open local ambient properties window in 🪟 Windows 11?
The window you want is System Properties, and Environment Variables is inside it. Press Win+R, type sysdm.cpl, and press Enter. Open the Advanced tab, then click Environment Variables at the bottom of the window.
How to create environment variable?
To create an environment variable, open Environment Variables from System Properties and click New under User variables. Enter a name, such as MY_FOLDER, and a value, such as your project folder. Use underscores instead of spaces in the name. Click OK in each window, then reopen any programs that need it.
Still have a question?
Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.
Did this guide fix your problem?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!