This article explains how to set up environment variables in Windows 11.
Environment variables are a powerful feature in Windows systems. Various processes and applications use them to determine operational behaviors based on specific system-wide or user-specific settings.
They store configuration data and system state information that can be accessed by different software applications and services running on a Windows system.
You can customize your System’s behavior for different applications and tasks by setting up environment variables. For example, you can set a variable to specify the path to a specific tool or define a variable that controls the behavior of a specific application.
In Windows 11, environment variables can be created through System Properties, the Command Prompt, or PowerShell.
Using System Properties
To create an environment variable using System Properties, follow these steps:
Right-click the Start button and select System on the Power User menu.

Next, click the Advanced system settings link under “Related settings” on the right.

This will open the System Properties window with the Advanced tab selected. Click the Environment Variables… button at the bottom of the System Properties window.

To create a user-specific variable, under the “User variables for [Your Username]” section, click the New… button.
To create a system-wide variable (accessible to all users), under the “System variables” section, click the New… button.

In the New System Variable or New User Variable window, enter the variable’s Name and its Value.
Create User Variable:
Under the User variables for the [Username] section, click New. Then, type in the Variable name and Variable value.

Click OK to close the new variable window.

Create System Variable:
Under the System Variables section, click the New button. Then, enter the Variable name and Variable value.

Click OK again to close the Environment Variables window.
You might need to restart your System or log out and back in for some changes.
Using the Command Prompt
You can also create environment variables via Command Prompt.
First, open the Windows Terminal app as administrator. You can also right-click the Start button and select Windows Terminal (Admin).
In the Windows Terminal, open a Command Prompt tab by clicking the down arrow icon next to the new tab button and selecting Command Prompt.
Create User Variable
Type the command
setx VARIABLE_NAME "VARIABLE_VALUE"
Replace VARIABLE_NAME
with the name you wish to assign to the variable and VARIABLE_VALUE
with the actual value.
Example:
setx Downloads "C:\Users\rworl\Downloads"
Create System Variable:
Type the command
setx /M VARIABLE_NAME "VARIABLE_VALUE"
Replace VARIABLE_NAME
with the name you wish to assign to the variable and VARIABLE_VALUE
with the actual value.
Example:
setx /M Downloads "C:\Users\rworl\Downloads"
Using Windows PowerShell
You can create environment variables using Windows PowerShell.
First, open the Windows Terminal app as administrator. Right-click the Start button and select Windows Terminal (Admin) on the Power User menu.
In the Windows Terminal, open a PowerShell tab if it’s not already open by default.
Create a User Variable
For a user-specific variable, replace Machine
with User
:
[System.Environment]::SetEnvironmentVariable('VARIABLE_NAME', 'VARIABLE_VALUE', [System.EnvironmentVariableTarget]::User)
.
Example:
[Environment]::SetEnvironmentVariable("Downloads","C:\Users\Richard\Downloads","User")
Create a System Variable
Type the command
[System.Environment]::SetEnvironmentVariable('VARIABLE_NAME', 'VARIABLE_VALUE', [System.EnvironmentVariableTarget]::Machine)
Example:
[Environment]::SetEnvironmentVariable("Downloads","%UserProfile%\Downloads","Machine")
After using the command line methods, the environment variable is immediately available in new Command Prompt or PowerShe instances.
However, you may still need to restart applications or the System to see the changes everywhere.
Verifying the Creation of the Variable
To confirm that your environment variable has been set, you can use the Command Prompt or PowerShell to echo its value:
- In Command Prompt:
echo %VARIABLE_NAME%
- In PowerShell:
$env:VARIABLE_NAME
If the environment variable has been successfully created, the commands above should display its value.
That should do it!
Conclusion:
- Environment variables in Windows 11 are a powerful feature that can be used to store configuration data and system state information.
- Users can customize system behavior for applications and tasks by setting up environment variables.
- This article provides detailed steps for creating environment variables using System Properties, Command Prompt, and Windows PowerShell in Windows 11.
- After creating environment variables, users can verify their successful creation using Command Prompt or PowerShell.
- Feel free to leave a comment if you have any feedback or additional information to share regarding this guide.
Leave a Reply