Table of Contents
How to set and use environment variables on Windows 11?
1. Using the Settings app
2. Use the Command Prompt
3. Use Windows PowerShell
How to edit environment variables on Windows 11?
2. Use the Registry Editor
How to get the list of environment variables in Windows?
Home Common Problem 11 Ways to Set Environment Variables on Windows 3

11 Ways to Set Environment Variables on Windows 3

Sep 15, 2023 pm 12:21 PM
variable environment click

在 Windows 3 上设置环境变量的 11 种方法

Setting environment variables on Windows 11 can help you customize your system, run scripts, and configure applications.

In this guide, we'll discuss three methods along with step-by-step instructions so you can configure your system to your liking.

There are three types of environment variables

  • System Environment Variables – Global variables are the lowest priority, accessible to all users and applications on Windows, and are typically used to define system-wide settings.
  • User Environment Variables – The higher the priority, these variables only apply to the current user and process running under that account, and are set by the user or application running under that account .
  • Process Environment Variables – With the highest priority, they are temporary and apply to the current process and its sub-processes, providing runtime information or customization to the program.

How to set and use environment variables on Windows 11?

1. Using the Settings app

  1. press to open Settings. WindowsI
  2. Go to System and click About. 在 Windows 3 上设置环境变量的 11 种方法
  3. Click the Advanced System Settings link. 在 Windows 3 上设置环境变量的 11 种方法
  4. In the "System Properties" window, click "Environment Variables".在 Windows 3 上设置环境变量的 11 种方法
  5. Next, in the Environment Variables window, you will see two types of variables. Select an option from User Variables in User or System Variables and click New. 在 Windows 3 上设置环境变量的 11 种方法
  6. In the following window, type the variable name without any spaces, and for the variable value, click the Browse Directory or Browse for File button. 在 Windows 3 上设置环境变量的 11 种方法
  7. Select the path and click OK.

2. Use the Command Prompt

  1. key, type cmd in the search bar, and click Run as administrator. Windows在 Windows 3 上设置环境变量的 11 种方法
  2. To add a temporary variable to the system, use this command after replacing the variable name and variable value with the desired variable and hit: Enter <strong>set VariableName = Variablevalue</strong>在 Windows 3 上设置环境变量的 11 种方法
  3. set command is used to define an environment variable in the process, which is ignored , and is deleted after the window is closed.
  4. To set an environment variable permanently, type the following command after replacing Variablename with the variable name and Value with the value you want to set, and then press: Enter<strong> setx Variablename Value /m</strong>在 Windows 3 上设置环境变量的 11 种方法
  5. Type the following command to list path variables and click: Enter<strong>echo %PATH%</strong>
  6. Copy and paste the following command to add another variable to the path directory; replace the PATH value with the path you want to add and press: Enter<strong>setx PATH "%PATH%; PATH Value</strong>在 Windows 3 上设置环境变量的 11 种方法
  7. Refresh the "Environment Variables" window to see the newly added path.

3. Use Windows PowerShell

  1. key, type PowerShell, and then click Run as administrator. Windows在 Windows 3 上设置环境变量的 11 种方法
  2. Type the following command to list path variables and press: [Environment]::GetEnvironmentVariable("PATH") Enter
  3. Copy and paste the following command to replace PATH in Declare a path variable after the path to be added and clicked: Enter<strong>$Variable_Name = "PATH"</strong>在 Windows 3 上设置环境变量的 11 种方法
  4. To change the variable To add to the list of path variables, use this command after replacing the folder PATH with the path you declared and press: [Environment]::SetEnvironmentVariable("folder PATH", "$PATH;$Variable_Name") Enter
  5. Restart the computer for the changes to take effect.

You can use any method to add new or missing environment variables to prevent the system from Problems such as input environment options not found

How to edit environment variables on Windows 11?

1. Using the Settings app

  1. Press to open Settings, then go to System, then About ,Then click "Advanced System Settings". WindowsI
  2. Click Environment Variables, then select the variable you want to edit and click Edit. 在 Windows 3 上设置环境变量的 11 种方法
  3. Make your changes and click OK in all three windows to save your changes. 在 Windows 3 上设置环境变量的 11 种方法
  4. Restart the Environment Variables window to see the changes.

2. Use the Registry Editor

  1. Press to open the "Run" dialog box. WindowsR在 Windows 3 上设置环境变量的 11 种方法
  2. Type regedit and click OK to open Registry Editor .
  3. If you want to change user variables, navigate to this path: <strong>Computer\HKEY_CURRENT_USER\Environment</strong>在 Windows 3 上设置环境变量的 11 种方法
  4. For system variables, go to Go to the following path: <strong>Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment</strong>在 Windows 3 上设置环境变量的 11 种方法
  5. If you want to rename the variable name, right click and select "Rename".
  6. To edit the value data, double-click the variable, change the value data, and click OK. 在 Windows 3 上设置环境变量的 11 种方法
  7. Restart your computer to save changes.

3. Use Windows PowerShell

  1. Use the same steps above to open Windows PowerShell with administrator privileges.
  2. Type the following command to get the current value of a variable. After replacing VARIABLENAME with the variable name, press: Enter<strong>$Env: VARIABLENAME</strong>在 Windows 3 上设置环境变量的 11 种方法
  3. Next, to update or edit the value, copy and paste the following command after replacing VARIABLEANME with the variable name and NEWVALUE with the value you want to add, then click: Enter<strong>$Env: VARIABLENAME = "NEWVALUE"</strong>
  4. Restart your computer to save changes.

How to get the list of environment variables in Windows?

To get a list of environment variables in Windows 11, you can open a command prompt with administrator rights and type Settings and hit .Enter

在 Windows 3 上设置环境变量的 11 种方法

In Powershell, with administrator rights to get a list of environment variables, copy and paste the following command and hit: Enter<strong>[System. Environment]::GetEnvironmentVariables()</strong>

在 Windows 3 上设置环境变量的 11 种方法

Read this guide if you want to print the list of environment variables obtained on PowerShell to apply the same settings on another computer.

Where are Windows environment variables stored?

You can find environment variables in the Registry Editor. System variables are located in Computer\HKEY_LOCAL_MACHINE\System\Current Control Set\Control\Session Manager\Environment, where user variables are located in <strong>Computer\HKEY_CURRENT_USER\Environment</strong>

Setting environment variables on Windows 11 can help you customize system settings; however, you must always be careful when changing system variables.

Remember to double-check variable names and values, and always create a backup of Registry Editor before making changes.

The above is the detailed content of 11 Ways to Set Environment Variables on Windows 3. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to enable or disable DLNA on Windows 11 How to enable or disable DLNA on Windows 11 Sep 28, 2023 pm 11:05 PM

DLNA streaming has been around for a long time and is considered one of the more user-friendly options. Given its compatibility with a variety of devices and systems, you shouldn’t have problems connecting to one. So, let us understand how to enable DLNA in Windows 11. There are two methods, use the built-in Windows DLNA (Digital Living Network Alliance) feature or install a third-party application. While the former works well and provides the best experience, you can try the app with its enhanced feature set. We will list both options. What are the benefits of using DLNA? DLNA allows media streaming across devices on the network, provided the streaming device is compatible with the standard. Once set up on a smart TV or other system, you can

Windows 11 Guide: How to adjust the display resolution in Hyper-V Windows 11 Guide: How to adjust the display resolution in Hyper-V Sep 23, 2023 pm 08:25 PM

If you are using Hyper-V to run virtual machines on a Windows 11 machine, you may need to change the display resolution of one or both VMs. In this guide, we will introduce simple methods and step-by-step instructions to adjust and optimize display resolution in Hyper-V environment. How to adjust screen resolution in Hyper-V? Before moving on to the detailed steps to change Hyper-V screen resolution on Windows 11, be sure to complete the following checks for smoother operation: Make sure you are logged in with an administrator account. Make sure graphics drivers are updated. Back up important data in the VM. Make sure Hyper-V is enabled. 1. Setting up using Hyper-V First, we will enable enhanced session mode; for this

Solution: Your organization requires you to change your PIN Solution: Your organization requires you to change your PIN Oct 04, 2023 pm 05:45 PM

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

How to properly calibrate your Xbox One controller on Windows 11 How to properly calibrate your Xbox One controller on Windows 11 Sep 21, 2023 pm 09:09 PM

Since Windows has become the gaming platform of choice, it's even more important to identify its gaming-oriented features. One of them is the ability to calibrate an Xbox One controller on Windows 11. With built-in manual calibration, you can get rid of drift, random movement, or performance issues and effectively align the X, Y, and Z axes. If the available options don't work, you can always use a third-party Xbox One controller calibration tool. Let’s find out! How do I calibrate my Xbox controller on Windows 11? Before proceeding, make sure you connect your controller to your computer and update your Xbox One controller's drivers. While you're at it, also install any available firmware updates. 1. Use Wind

How to show folder size on Windows 11? How to show folder size on Windows 11? Sep 23, 2023 pm 06:13 PM

By default, Windows 11 does not display folder sizes in File Explorer, however, you can make certain changes in Explorer settings to make them visible. In this guide, we will discuss some of the easiest ways to display folder sizes so that you can effectively manage disk space on your PC. How to check the size of a folder on Windows 11? 1. Use the folder's Properties window to open a Windows Explorer window by pressing +. WindowsE Go to the folder whose size you want to check, right-click on it and select "Properties" from the context menu. In the folder properties window, go to the "General" tab and find the "Size" section to find out how much space the folder takes up. 2. Enable "

How to Completely Remove Unwanted Display Languages ​​on Windows 11 How to Completely Remove Unwanted Display Languages ​​on Windows 11 Sep 24, 2023 pm 04:25 PM

Work on the same setup for too long or share your PC with others. You may have some language packs installed, which often create conflicts. So, it’s time to remove unwanted display languages ​​in Windows 11. Speaking of conflicts, when there are multiple language packs, inadvertently pressing Ctrl+Shift changes the keyboard layout. If not taken care of, this can be a hindrance to the task at hand. So, let’s jump right into the method! How to remove display language from Windows 11? 1. From Settings press + to open the Settings app, go to Time & Language from the navigation pane and click on Language & Region. WindowsI click the ellipsis next to the display language you want to remove and select Remove from the pop-up menu. Click "

Resolved: Windows 11 23H2 not showing up in Windows Update Resolved: Windows 11 23H2 not showing up in Windows Update Nov 08, 2023 pm 02:46 PM

Microsoft recently rolled out Windows 11 version 23H2 to all compatible devices, but it didn't appear for many people. This version was earlier only available to users in the Beta and Dev channels. Ever since its public release, users have been eager to try out the latest operating system version. First, Microsoft rolls out updates in stages, with some users receiving them before others. This does not mean that your device is not compatible or will not receive updates. However, if a few days have passed, you should check for problems. Why doesn't Windows1123H2 appear? When the device blocks newer versions of Windows, there are corrupt update components, or the computer fails due to lack of TPM2.0 or Secure Boot

How to unapply a theme (change or remove) in Windows 11 How to unapply a theme (change or remove) in Windows 11 Sep 30, 2023 pm 03:53 PM

Themes play an integral role for users who wish to modify their Windows experience. It may change the desktop background, animations, lock screen, mouse cursor, sounds, icons, etc. But what if you want to remove themes in Windows 11? It's equally simple and there are options available, both for the current user profile and for the entire system, i.e. all users. Additionally, you can even delete custom themes in Windows 11 if they are no longer used for that purpose. How do I find my current topic? Press + to open the Settings app &gt; Go to Personalization from the navigation pane &gt; Click on Themes &gt; The current theme will be listed on the right. How about WindowsI