A Guide to Setting up Environment Variables in Windows 11

|

|

This article outlines the steps to create environment variables in Windows 11, which configure operational behaviors for applications. Users can set system-wide or user-specific variables via System Properties, Command Prompt, or PowerShell. Instructions include accessing the correct settings, inputting the variable names and values, and confirming their creation. Restarting the system or applications may be…

This article explains how to set up environment variables in Windows 11.

Environment variables are a powerful feature in Windows systems used by various processes and applications to determine operational behaviors depending on specific system-wide or user-specific settings.

They are used to 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, creating environment variables can be done through the 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.

windows about advanced system settings
windows about advanced system settings

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.

Enviroment Variables button add

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.

Windows 11 new environment variables add

Click OK to close the new variable window.

Windows 11 new environment variables added

Create System Variable:

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

Environment variables Windows 11

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:

This post showed you how to create environment variables in Windows 11. Please use the comments form below if you find errors or have something to add.

Like this:



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.