How to set environment variable in windows

Introduction

Environment variables are key-value pairs a system uses to set up a software environment. The environment variables also play a crucial role in certain installations, such as installing Java on your PC or Raspberry Pi.

In this tutorial, we will cover different ways you can set, list, and unset environment variables in Windows 10.

How to set environment variables in Windows

Prerequisites

  • A system running Windows 10
  • User account with admin privileges
  • Access to the Command Prompt or Windows PowerShell

Check Current Environment Variables

The method for checking current environment variables depends on whether you are using the Command Prompt or Windows PowerShell:

List All Environment Variables

In the Command Prompt, use the following command to list all environment variables:

set
List all environment variables using the Command Prompt

If you are using Windows PowerShell, list all the environment variables with:

Get-ChildItem Env:
List all environment variables using Windows PowerShell

Check A Specific Environment Variable

Both the Command Prompt and PowerShell use the echo command to list specific environment variables.

The Command prompt uses the following syntax:

echo %[variable_name]%
Checking a specific environment variable using the Command Prompt

In Windows PowerShell, use:

echo $Env:[variable_name]
Checking a specific environment variable using Windows PowerShell

Here, [variable_name] is the name of the environment variable you want to check.

Follow the steps to set environment variables using the Windows GUI:

1. Press Windows + R to open the Windows Run prompt.

2. Type in sysdm.cpl and click OK.

Run sysdm.cpl

3. Open the Advanced tab and click on the Environment Variables button in the System Properties window.

Find the Environment Variables button in the Advanced tab

4. The Environment Variables window is divided into two sections. The sections display user-specific and system-wide environment variables. To add a variable, click the New… button under the appropriate section.

Click on the New... button to add a variable

5. Enter the variable name and value in the New User Variable prompt and click OK.

Enter the new variable name and value

Set Environment Variable in Windows via Command Prompt

Use the setx command to set a new user-specific environment variable via the Command Prompt:

setx [variable_name] "[variable_value]"

Where:

  • [variable_name]: The name of the environment variable you want to set.
  • [variable_value]: The value you want to assign to the new environment variable.

For instance:

setx Test_variable "Variable value"
Setting a user-specific environment variable via the Command Prompt

Note: You need to restart the Command Prompt for the changes to take effect.

To add a system-wide environment variable, open the Command Prompt as administrator and use:

setx [variable_name] "[variable_value]" /M
Setting a system environment variable via the Command Prompt

Unset Environment Variables

There are two ways to unset environment variables in Windows:

Unset Environment Variables in Windows via GUI

To unset an environment variable using the GUI, follow the steps in the section on setting environment variables via GUI to reach the Environment Variables window.

In this window:

1. Locate the variable you want to unset in the appropriate section.

2. Click the variable to highlight it.

3. Click the Delete button to unset it.

Unset environment variables in Windows via GUI

Unset Environment Variables in Windows via Registry

When you add an environment variable in Windows, the key-value pair is saved in the registry. The default registry folders for environment variables are:

  • user-specific variables: HKEY_CURRENT_USEREnvironment
  • system-wide variables: HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment

Using the reg command allows you to review and unset environment variables directly in the registry.

Note: The reg command works the same in the Command Prompt and Windows PowerShell.

Use the following command to list all user-specific environment variables:

reg query HKEY_CURRENT_USEREnvironment
Listing all user-specific environment variables in the registry

List all the system environment variables with:

reg query "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment"
Listing all system environment variables in the registry

If you want to list a specific variable, use:

reg query HKEY_CURRENT_USEREnvironment /v [variable_name]
Listing a specific user environment variable in the registry

or

reg query "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment" /v [variable_name]
Listing a specific system environment variable in the registry

Where:

  • /v: Declares the intent to list a specific variable.
  • [variable_name]: The name of the environment variable you want to list.

Use the following command to unset an environment variable in the registry:

reg delete HKEY_CURRENT_USEREnvironment /v [variable_name] /f
Unsetting a user-specific environment variable from the registry

or

reg delete "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment" /v [variable_name] /f
Unsetting a system environment variable from the registry

Note: The /f parameter is used to confirm the reg delete command. Without it, entering the command triggers the Delete the registry value EXAMPLE (Yes/No)? prompt.

Run the setx command again to propagate the environment variables and confirm the changes to the registry.

Note: If you don’t have any other variables to add with the setx command, set a throwaway variable. For example:

setx [variable_name] trash

Conclusion

After following this guide, you should know how to set user-specific and system-wide environment variables in Windows 10.

Looking for this tutorial for a different OS? Check out our guides on How to Set Environment Variables in Linux, How to Set Environment Variables in ZSH, and How to Set Environment Variables in MacOS.

Переменные среды Windows 11 и Windows 10Настройка переменных среды Windows может помочь сократить время, необходимое для набора команд в командной строке или, если вы часто пишете скрипты для собственных задач, сделать их более читаемыми. В большинстве случаев обычные пользователи добавляют записи в системную переменную среды PATH, хотя бывают и другие задачи.

В этой пошаговой инструкции базовая информация о том, как открыть переменные среды Windows 11 и Windows 10, создать или отредактировать их.

Что такое переменные среды

Переменные среды в Windows — записи о расположении системных папок, свойствах системы и другие, которые доступны для любой программы или скрипта.

Одна из наиболее часто используемых переменных среды — PATH, указывающая на папки, в которых выполняется поиск файлов, вызываемых в командной строке, терминале Windows, файле bat или из других источников. В качестве примера её назначения:

  • Если вы откроете командную строку (или диалоговое окно «Выполнить»), введёте regedit и нажмете Enter — вы сможете запустить редактор реестра, не указывая полный путь к файлу regedit.exe, поскольку путь C:\Windows добавлен в переменную среды Path.
  • Если же тем же образом в командной строке написать имя программы, путь к которой не добавлен в Path (chrome.exe, adb.exe, pip и другие), вы получите сообщение «Не является внутренней или внешней командой, исполняемой программой или пакетным файлом».

Если предположить, что вы часто используете команды adb.exe (например, для установки приложений Android в Windows 11), pip install (для установки пакетов Python) или любые другие то для того, чтобы не писать каждый раз полный путь к этим файлам, имеет смысл добавить эти пути в переменные среды.

Также вы можете добавлять и иные переменные среды (не обязательно содержащие пути), а в дальнейшем получать и использовать их значения в сценариях BAT (командной строки) или PowerShell. Пример получения и отображения значения системной переменной PATH для обоих случаев:

echo %PATH%
echo $Env:PATH

Получить список всех переменных среды в командной строке и PowerShell соответственно можно следующими командами:

set
ls env:

Редактирование переменных среды Windows 11/10

Прежде чем приступать, учтите: изменение системных переменных среды по умолчанию может привести к проблемам в работе системы, не удаляйте уже имеющиеся переменные среды. Возможно, имеет смысл создать точку восстановления системы, если вы не уверены в своих действиях.

  1. Чтобы открыть переменные среды Windows вы можете использовать поиск в панели задач (начните вводить «Переменных» и откройте пункт «Изменение системных переменных среды») или нажать клавиши Win+R на клавиатуре, ввести sysdm.cpl и нажать Enter. Открыть изменение переменных среды в Windows
  2. На вкладке «Дополнительно» нажмите кнопку «Переменные среды…» Переменные среды в параметрах системы Windows
  3. В разделе «Переменные среды пользователя» (если требуется изменение только для текущего пользователя) или «Системные переменные» выберите переменную, которую нужно изменить и нажмите «Изменить» (обычно требуется именно это), либо, если необходимо создать новую переменную — нажмите кнопку «Создать». В моем примере — добавляем свои пути в системную переменную Path (выбираем эту переменную и нажимаем «Изменить»). Создание и изменение переменных среды Windows
  4. Для добавления нового значения (пути) в системную переменную в следующем окне можно нажать кнопку «Создать», либо просто дважды кликнуть по первой пустой строке, затем — ввести нужный путь к папке, содержащей нужные нам исполняемые файлы. Изменение переменно PATH
  5. Также вы можете использовать кнопку «Изменить текст», в этом случае окно изменения системной переменной откроется в ином виде: имя переменной, а ниже — её значение. В случае указания путей значение будет представлять собой все пути, хранящиеся в переменной, разделенные знаком «точка с запятой». Изменение имени и значения системной переменной среды
  6. При создании новой переменной среды окно будет тем же, что и в 5-м шаге: необходимо будет указать имя системной переменной в верхнем поле, а её значение — в нижнем.

После создания или изменения переменной среды и сохранения сделанных настроек, переменная или обновленные значения сразу становятся доступны для текущего пользователя или в системе в целом в зависимости от того, какие именно переменные редактировались или создавались. Также есть методы добавления переменных среды в командной строке или PowerShell, подробнее в статье: Как добавить путь в переменную среды PATH

The environment variables are the key-value pairs that act as information containers for all the programs running on Windows. Simply put, they are the string variables an OS uses to manage all the apps and services.

Every application has its own set of environment variables, and it helps them determine where to install and store files. These variables contain names and values that help control the operational environment. Further, they have a significant effect and enable your computer’s active processes.

Without environment variables, you’ll need to inform your scripts every time to find the same path to a specific file. But if you set a dedicated variable, the information becomes available everywhere.

Whether you’re trying to feed data into a database or secure your configuration, the environment variables will help keep your code and data separated. Apart from that, they hold the following importance on Windows or any other OS:

  • Helps secure sensitive information
  • No need to worry about scheduled tasks and production mistakes
  • Provides better development experience
  • Easy navigation and configuration

Table of Contents

In Windows, the environment variables are categorized into two – User and System. While the former deals with user-defined settings (user profiles, files, etc.), the latter contains the values used by the operating system.

In this section, you will learn how to set Windows environment variables via the graphical user interface, command line interface (Command Prompt and Windows Powershell), and Registry Editor. So, without further delay, let’s get right into them in detail.

Using Windows GUI

Before setting up a Windows environment variable in the graphical user interface, you’ll need to navigate to the dedicated window: 

  1. Use Windows + I to launch Settings on your PC.
  2. Now, move to System > About.
    settings system about
  3. Here, expand Device Specifications and select Advanced system settings.
    device specifications advanced system settings
  4. This will open the Advanced tab in the System Properties dialogue box. Here, find and click on the Environment Variables button.
    environment variables button

Another way to open Environment Variables window is from the Control Panel utility. Kindly follow the below instructions on how you can do so:

  1. Press Windows + R and run the control Command to open Control Panel.
  2. Now, navigate to User Accounts.
    user accounts in control panel
  3. Again, choose User Accounts.
    user accounts
  4. Then, select Change my environment variables from the left pane.
    change my environment variables

Alternatively, you can directly launch it from the Run dialogue box by running the following command:
rundll32.exe sysdm.cpl,EditEnvironmentVariables
Also, this is possible from the Start menu, where you can search for “Edit the system environment variables” or “Edit environment variables for your account”.

Once the Environment Variables window pops up, go through the following guide to learn how to set the system environment variables on Windows 11:

  1. Press the New button under ‘User variables for [Your PC Name]’ to add a user variable.
    new button under user variables
    For adding a new system variable, use the New button under the System variables section.
    new button under system variables
  2. Next, enter a desired name in the Variable name field.
    edit variable name
  3. To add a path, press Browse Directory or Browse Field. Now, navigate to the path and tap the Open button. If you already know the correct location or want to add different data, you can directly enter it in the Variable value field.
  4. Finally, click Ok and check the list.
    set variable value

You can select the system or user variable if you want to change its name or value. Then, press the Edit button, and proceed with the same steps as above. Likewise, to delete an existing environment variable, select it and choose Delete.

In Registry Editor

Another way to set Windows environment variables is from the built-in Registry Editor tool. In fact, this is the precise location where all the user and system values are stored. Here’s a quick guide on how to do it the right way:

  1. Press Windows + R and run the following to open the utility:
    regedit.exe
  2. Now, copy and paste one of the below paths to view all the user or system variables on your computer:
    Computer\HKEY_CURRENT_USER\Environment (for user)
    registry editor go to user variable path
    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment (for system)
  3. Next, go to Edit > New.
  4. Here, select any of the following value options – String, Binary, DWORD, QWORD, Multi-string, Expandable String. 
    registry editor new and select one value
  5. Move to the right pane and name the variable.
    set user variable in registry editor
  6. Then, double-click on it and enter an appropriate value in the Value data field.
  7. Hit Ok, which should set the Windows environment variable.
    edit user variable value

To edit the value, simply double-click the variable and change it to an appropriate one. Furthermore, you can right-click and pick Delete to remove the environment variable permanently.

In Command Prompt

If you prefer CLI (Command Line Interface) over GUI, the good news is that you can use simple commands to set Windows environment variables. Although you can create both user and system variables, there’s no individual section to display each of them.

Follow the below steps to view, set, edit, and delete Windows environment variables using Command Prompt:

  1. Firstly, press the Windows key to open the start menu. Then, search and launch Command Prompt.
  2. Use the below command to view all the environment variables (for both user and system):
    set
    set command in command prompt
  3. Next, you can use the below syntax to create a user variable of your own:
    setx variable_name “variable_value”
    For demonstration, we have used the following command to create a user variable named “Example” and set its value to “0”:
    setx Example “0”
    setx command in command prompt
    To create a system environment variable, you’ll need to use a slightly different syntax:
    setx /m variable_name “value”
    setx m command in command prompt
  4. Now, restart the Command Prompt and use the set command again to confirm that the environment variable is created successfully.
    set command to check if the environment variable is set
  5. To edit the value, you can use the same syntax used to create the environment variable. Here’s a simple example that should clear your doubt:
    setx Example “1” (for user)
    edit user environment variable in command prompt
    setx /m variable “1” (for system)
    edit system environment variable in command prompt
  6. Restart CMD and use the set command again to check the edited value.
    changed user environment variable
  7. In case you wish to delete an environment variable, you’ll need to use the following registry commands:
    REG delete HKCU\Environment /F /V variable_name (user)
    delete user environment variable
    REG delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /F /V variable_name (system)
    delete system environment variable

In Windows Powershell

Although Command Prompt is quite popular, most advanced Windows users prefer Powershell due to its extensibility. If you fall into this category, follow our guide to view, set, edit, and delete Windows environment variables via Powershell:

  1. Press Windows + X and select Windows Terminal to enter the Powershell interface.
    quick link menu windows terminal
  2. Here, use the below cmdlets to view the present environment variables on your PC:
    Get-ChildItem Env: (view all environment variables)
    get childitem env
    [Environment]::GetEnvironmentVariables("User") (view the user variables)
    view user variables
    [Environment]::GetEnvironmentVariables("Machine") (view the system variables)
    get system environment variables
  3. To add a new variable, kindly use the appropriate syntax from below:
    [Environment]::SetEnvironmentVariable("variable_name","value","User") (for user)
    powershell add user variable
    [Environment]::SetEnvironmentVariable("Ex","0","Machine") (for system)
    powershell add system variable
  4. Now, simply use the view cmdlet to confirm that the variable was created.
    check if variable is added in powershell
  5. If you’re unsatisfied with the value, you can quickly change it using the same commands used for creating the environment variable.
  6. To delete the Windows environment variable, kindly have a look at the below command lines:
    [Environment]::SetEnvironmentVariable("variable_name", $null ,"User") (user)
    delete user environment variable in powershell
    [Environment]::SetEnvironmentVariable("variable_name", $null ,"Machine") (system)
    delete system environment variable in powershell

Environment variables may sound like technical jargon, but they are crucial components of your Windows 11 operating system. These variables store essential information that helps your computer run smoothly and ensures that various software applications can find the resources they need.

Whether you’re a power user, developer, or just someone looking to troubleshoot issues on your PC, understanding how to set environment variables in Windows 11 is a valuable skill.

In this comprehensive guide, we will learn about environment variables, walk through the process of setting them, learn how to edit them, and even delve into the Windows PATH variable. By the end of this article, you’ll be equipped with the knowledge to harness the potential of environment variables on your Windows 11 machine.

What are Environment Variables?

Before we dive into setting environment variables, let’s understand what they are and why they are essential. Environment variables are dynamic values that store information about the system environment.

These variables can be system-wide or user-specific and play a vital role in how applications and the operating system itself function. They serve as placeholders for various system properties, directories, and user preferences.

Here are some key aspects of environment variables:

System Configuration

Environment variables store information about system configuration, such as the location of system files, system paths, and system settings. For example, the “SystemRoot” variable stores the path to the Windows system folder.

User Preferences

They can also hold user-specific settings and preferences, making them adaptable to individual users. For instance, you can create a custom environment variable to store your preferred default download directory.

Access By Applications

Applications and scripts can access these variables to retrieve critical information, like the location of essential files or temporary storage directories. For instance, software installations often use environment variables to determine where to store program files.

Modifiable

In Windows, users have the ability to modify or add environment variables to customize their computing experience. This flexibility allows you to tailor your system to your specific needs.

Now that we have a grasp of what environment variables are let’s delve into how to set them in Windows 11.

Setting environment variables in Windows 11 can be done through the System Properties menu. Follow these steps to create a new environment variable:

1. Press Win + X and select “System” from the context menu.

2. Under the System window, click the “Advanced system settings” on the left-hand side.

Advanced system settings

3. In the System Properties window, click the “Environment Variables…” button in the “Advanced” tab.

4. Under the “User variables” or “System variables” section, depending on whether you want the variable to be user-specific or system-wide, click the New button.

5. Enter a name for your variable in the “Variable name” field. Variable names are case-insensitive.

6. In the “Variable value” field, provide the value you want the variable to hold. This value can be a directory path, a string, or even a numerical value.

7. Next, click OK to create the new environment variable.

8. Finally, remember to click the OK button under the main Environment Variables window; otherwise, the newly created variable won’t work.

Congratulations! You’ve successfully created a new environment variable in Windows 11. Now, let’s explore how to use the newly created environment variable.

Using the Newly Created Environment Variable

Once you’ve created an environment variable, you can utilize it in various ways, such as configuring applications, setting default directories, or even automating tasks. Here’s how to use the newly created environment variable:

Through Command Prompt or PowerShell

1. Search for Command Prompt or PowerShell, right-click on the app icon, and select Run as Administrator.

run command prompt as administrator

2. Type the echo %variablename% command in the Command Prompt window and press enter. Replace the variablename with the variable name you created.

Command to use Environment Variable

Through Run Command Window

1. Press Windows + R to launch the Run Command Window.

2. Type the %variablename% command and hit enter. Replace the variablename with the variable name you created.

Run command for Environment Variables

Now that you know how to use environment variables, let’s explore how to edit them if the need arises.

How to Edit Environment Variables in Windows 11

Editing environment variables in Windows 11 is a straightforward process. Here’s how to do it:

1. Follow the same steps as described earlier to access the “Environment Variables” window under System Properties.

2. In the “Environment Variables” window, select the variable you want to edit from the list under “User variables” or “System variables” and click the Edit button.

edit Environment Variable

3. In the “Edit User Variable” window, you’ll see the current variable name and value. Modify the variable name or value as needed.

edit user variable

4. Click OK to save your changes.

5. Finally, remember to click the OK button under the main Environment Variables window; otherwise, changes won’t be effective.

You’ve successfully edited an environment variable in Windows 11.

What is Windows PATH Variable

The PATH variable in Windows is a crucial environment variable that specifies a set of directories where executable files are located. When you run a command in the Command Prompt or PowerShell, Windows searches these directories for the corresponding executable.

Understanding and managing the PATH variable can help you streamline your workflow by allowing you to execute commands from any location in the command prompt.

How to Set Windows PATH Variable

To set or modify the Windows PATH variable in Windows 11, follow these steps:

1. Open the “Environment Variables” window as described earlier.

2. In the “Environment Variables” window, under “User variables” or “System variables,” find and select the “Path” variable and click the Edit button.

PATH variable

3. In the “Edit Environment Variable” window, you’ll see a list of paths. Click New to add a new path, and enter the directory path you want to add.

rdit or add new variable to PATH

4. To modify an existing path, select it and click Edit.

5. Click OK to save your changes.

The Windows PATH variable has been updated with your new paths or modifications.

FAQs

Can I delete environment variables I no longer need?

Yes, you can delete environment variables. To do this, select the variable in the “Environment Variables” window and click the “Delete” button.

What happens if I create a user-specific environment variable and then delete my user account?  

When you delete your user account, the user-specific environment variables associated with that account are also deleted.

Can I use environment variables in batch scripts or PowerShell scripts?

Yes, environment variables are commonly used in scripts to make them more dynamic and adaptable to different system configurations.

Take Control of Environment Variables

Understanding how to set, use, and manage environment variables in Windows 11 is a valuable skill that can enhance your computing experience and productivity. Environment variables are the building blocks that allow you to customize your system, configure applications, and automate tasks.

By following the steps outlined in this guide, you’ve gained the knowledge to set up and use the environment variables and the Windows PATH variable, making your Windows 11 experience more versatile and efficient.

Windows environment variables are very important, it plays an important role in Windows OS. This article will tell you how to set windows environment variables both on GUI and command line.

1. Set Windows Environment Variables On GUI.

  1. Open a Windows Explorer, right-click This-PC on the left side, then click the Properties menu item in the popup menu list, then it will popup the System window.
    windows-10-right-click-this-pc-properties-menu
  2. Click the Advanced system settings item in the popup window left side, it will popup the System Properties window.
  3. Click the Environment Variables… button at the bottom-right of the System Properties window, it will popup the Environment Variables window.
    windows-10-advanced-system-settings-environment-variables-edit-window
  4. There are two parts in the Environment Variables dialog. The upper part area is the User variables ( only available to this user ) list, the lower part area is the System variables ( available to all users that use this Windows OS ) list.
  5. Click the New… button to add a new environment variable, input variable name ( such as CLASSPATH), and variable value ( such as C:\ ) in the popup dialog, click the OK button to save it.
  6. To edit a windows environment variable, just select it and click the Edit… button. For example, we select the system variable Path and click the Edit… button, then you can add a new path value or edit the existing path value in the popup dialog.
  7. The variable name is just a string, and if one environment variable has multiple values, you should use ; to separate them.

2. Set Windows Environment Variables In Command-Line.

If you want to get and set windows environment variables in a shell script, you had better use the command line to process it.

2.1 Print Windows Environment Variables In Command-Line.

  1. Run the command set in the Dos window to show current environment variables.
    C:\WorkSpace>set
    ALLUSERSPROFILE=C:\ProgramData
    ......
    OS=Windows_NT
    Path=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;
    ......
  2. Run the command  echo %variable-name% in the Dos window to print the special environment variable value.
    C:\WorkSpace>echo %PATH%
    C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
  3. Run command Get-ChildItem Env: in the Windows PowerShell window to print all environment variables.
    PS C:\Users\song zhao> Get-ChildItem Env:
    
    Name                           Value
    ----                           -----
    ALLUSERSPROFILE                C:\ProgramData
    APPDATA                        C:\Users\song zhao\AppData\Roaming
    CommonProgramFiles             C:\Program Files\Common Files
  4. Run command echo $Env:variable-name in Windows PowerShell window to print special environment variable value.
    PS C:\Users\song zhao> echo $Env:PATH
    C:\Program Files (x86)\Common Files\Oracle\Java\javapath;

2.2 Set Windows Environment Variables In Command-Line.

  1. We can run setx command in both Dos window and Windows PowerShell to set environment variables in the command line. The command format is setx variable-name variable-value.
    C:\WorkSpace>setx HELLO 'haha'
    
    SUCCESS: Specified value was saved.
    -------------------------------------------
    PS C:\Users\song zhao> setx ABC "C:\"
    
    SUCCESS: Specified value was saved.
  2. If the user environment variable does not exist, then it will add a new one. If the user environment variable name already exists, then it will overwrite it.
  3. To see the changes, you need to open a new Dos window or PowerShell window and run the command echo %HELLO% or echo %ABC% .
    C:\Users\song zhao>echo %HELLO%
    'haha'
    
    C:\Users\song zhao>echo %ABC%
    C:\
  4. If you want to set a system environment variable, you should first run Dos window or PowerShell window as administrator and then run the command setx variable-name variable-value /M, otherwise, you will encounter the error message ERROR: Access to the registry path is denied.
  5. In the below example, we use windows GUI to add a system environment variable TEST_VAR first, then we want to overwrite it in the command line. Because the Dos window is not opened as administrator, then an error message is thrown.
    PS C:\Users\song zhao> setx TEST_VAR "C:\" /M
    ERROR: Access to the registry path is denied.

We can also set environment variables in Windows registry, we will introduce it later in this article.

  • How to run postgresql windows
  • How to remove microsoft account from windows
  • How to open windows features
  • How to remove activate windows
  • How to open terminal windows 10