Let’s learn Various Ways to Set up Environment Variables on Windows 11. Environment variables are Windows System Variables (or user variables) that describe the environment in which apps run. It is easier than you think but more powerful than more than your imagination.
Environment variables can be provided to your application, such as the name of the computer, the name of the user account, and the current working directory. These variables play a crucial role in the proper function of your system and installed apps.
Environment variables, unlike other types of variables in PowerShell, are always stored as a string and cannot be empty. Also, unlike other variables, they are inherited by child processes, such as local background jobs and the sessions in which module members run. This makes environment variables well-suited to storing values that are needed in both parent and child processes.
Environment variables store information like system paths, temporary file locations, and other user-specific settings. Using Advance System Settings, command prompt, or Windows PowerShell you can set up environment variables.
- Install Ubuntu Terminal Environment on Windows 11 from Microsoft Store
- Easily Export SCCM Application from Staging to Prod Environment
How to Set up Environment Variables on Windows 11
Setting environment variables on Windows 11 helps users customize their system, run scripts, and configure applications using the environment. There are three types of environmental variables available and listed below.
- System Environment Variables: The global variables are at low priority. They can be accessed by all users and apps on Windows and are usually used to define system settings.
- User Environment Variables: It is a high priority. It only applies to the current user & the current processes run using the account. And also it can be set by the user or apps that run under that account.
- Process Environment Variables: This is with the highest priority, and it is temporary and applies to the existing process and its child processes, providing runtime information or customization for a program.
What are Environment Variables on Windows 11?
An environment variable is a user-definable value that can affect how running processes behave on a computer. Environment variables are part of the environment in which a process runs. For example, a running process can query the value of the TEMP environment variable to discover a suitable location to store temporary files, or the HOME or USERPROFILE variable to find the directory structure owned by the user running the process.
How to Set up Environment Variables on Windows 11 Using Windows Settings
You can open the Environment Variables using various methods in Windows. There are some methods described here. The first method is to open Environment Variables using the settings menu.
- Click on the Windows button then select Settings or you can simply press Win Key + I to directly open settings.
- Under System click on About.
- When About the window opens, click on the Advanced System Settings link.
- Then under the Advanced tab, click on the Environment Variable button
In the second method, you can type Environment Variables in the Search box on the Taskbar, then click the appropriate link as shown in the image below, then under the Advanced tab, click on the Environment Variable button as shown above.
In the third method, open the Run dialog box by pressing the Win key + R then type the following command or copy and paste it into the Run dialog box and press Enter to open the Environment Variables window.
rundll32.exe sysdm.cpl,EditEnvironmentVariables
When the Environment Variables window opens, you can see two types of variables User Variables for user or System variables. Then from both options choose one and click the New button available.
In the next window, type the variable name without any spaces, and for Variable Value, click the Browse Directory or Browse File button as per your requirement. Then press OK, and you see the created environment in the list and press OK.
How to Set up Environment Variables on Windows 11 Using Command Prompt
Open the command prompt in Administrator mode, press Win key + R, type CMD, and press Shift+Ctrl+Enter. Give access to user account control. Then to add a temporary variable to your system, use the following command after replacing VariableName & VariableValue as selected by you and press Enter.
Then type Set command is used to show all the environment variables within the process, and it will be deleted when the window is closed.
set VariableName = Variablevalue
To set environment variables permanently, type the following command after replacing the VariableName with the name of the variable and Value with the value you want to set and press Enter.
setx Variablename Value /m
Now for the path variables, type the echo %PATH% command to list all of them and hit Enter. Again type the setx PATH “%PATH%; PATH Value command to add another variable to the path directory. Replace the PATH value with the path you want to add and hit Enter. Then refresh the Environment variable window to see the newly added path.
How to Set up Environment Variables on Windows 11 Using PowerShell
You can set up the Environment variables on Windows 11 using PowerShell by typing PowerShell in the Search box and open with Administrator privilege.
Type the following command to list of path variables and hit Enter [Environment]::GetEnvironmentVariable(“PATH”), the list of paths shown in the PowerShell. Then type the command $Variable_Name = “Path” to declare a path variable after replacing PATH with the selected path by you want to add and hit Enter. Then restart your device to apply the changes.
How to Edit Environment Variables on Windows 11 Using Windows Settings
Click on the Windows button, then select Settings, or you can press Win Key + I to open settings directly. Under System, click on About. When About the window opens click on the Advanced System Settings link. Then, under the Advanced tab click on the Environment Variable button.
When the Environment Variables window opens, you can see two types of variables User Variables for user or System variables. Then, from both options, choose one and click the Edit button available. Make necessary changes and press OK. Restart the Environment variable windows to make an effect.
How to Edit Environment Variables on Windows 11 Using PowerShell
Open Windows PowerShell with administrator privileges using the same steps mentioned earlier. Type the $Env: VariableName command to get the current value of the variable by replacing VariableName with the variable name and press Enter.
Next, to update or edit the value, copy & paste the $Env: VariableName = “NewValue” command after replacing the VariableName with the name of the variable and NewValue with the value that you want to add, then hit Enter.
I hope the Various Ways to Set up Environment Variables on Windows 11 information is helpful. Please follow us on the HTMD Community and visit our website HTMD Forum, if you like our content. Suggest improvements, if any, and we love to know which topic you want us to explore next.
We are on WhatsApp. To get the latest step-by-step guides and news updates, Join our Channel. Click here – HTMD WhatsApp.
Author
Alok is a Master of Computer Applications (MCA) graduate. He loves writing on Windows 11 and related technologies. He likes to share his knowledge, quick tips, and tricks with Windows 11 or Windows 10 with the community.