Windows check environment variables

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.

Set Environment Variable in Windows via GUI

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.

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.

Was this article helpful?

YesNo

Настройка переменных среды 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

how to check environment variables in windows

Overview – Check
Environment Variables in Windows

Environment variables in Windows are used to store information that are used by applications and services. The Windows operating system defines a number of environment variables, and user applications and services can also further add additional environment variables.

When you start a Windows program, the operating system creates several environment variables that the program can use. These variables include the path to the application’s directory and any additional folders that the program requires access to.

It seems that you want to check compatibility issues among the numerous environment variables stored on your computer. By the end of this article, you’ll be able to list all environment variables in Windows:

Using System Properties

Using Command Prompt

Using PowerShell

Using Batch Script

Using System Information

Using Registry Editor

1. Check Environment
Variables using System Properties

Step 1: In the Start menu, search for “Edit the system environment variables” (without quotation marks) and hit the enter key.

type-edit-the-system-environment-variables-in-start-menu.webp

Edit System Environment Variables

Step 2: In the “Advanced” tab, click the “Environment Variables” button and all the environment variables on your system will be visible..

click-the-environment-variables-button-in-the-advanced-tab-in-advanced-system-properties.webp

“Environment Variables” Button

list-all-environment-variables-using-system-properties.webp

List of All Environment variables – Both User and System Environment Variables

2. Check Environment
Variables using Command Prompt

Step 1: Run the Command Prompt as an administrator from the Start menu.

command-prompt-icon-in-windows-11.webp

Command Prompt (CMD) Icon

Step 2: To list all the environment variables using Command Prompt, type the command “set” (without quotation marks).

command-to-list-environment-variables-in-windows-using-command-prompt.webp

Command To List Environment Variables using CMD

3. Check Environment
Variables using PowerShell

Step 1: Run the PowerShell as an administrator from the Start menu.

powershell-app-icon-in-windows-11.webp

PowerShell App Icon

Step 2: To list all the environment variables using PowerShell, type the command: “gci env:” (without quotation marks).

command-to-list-environment-variables-in-windows-using-powershell.webp

Command To List Environment Variables using PowerShell

4. Check Environment
Variables using Batch Script

Step 1: Right-click the desktop and add a new “Text Document”.

right-click-mouse-button-and-create-a-new-text-document-file.webp

Create New Document

Step 2: Copy and Paste the following script in the text document:

@ECHO OFF
set
pause

batch-script-to-show-environment-variables-in-windows.webp

Batch Script To Show Environment Variables In Windows

Step 3: Click the “File” button on the top left corner of the window and click the “Save As” option.

click-the-file-button-on-top-bar-and-click-the-save-as-button-to-save-the-script.webp

“File” Button > “Save as” Button

Step 4: Change the file extension to “File-Name.bat’ (.bat is the new extension), choose the desired location where you want to save the file and click the “Save” button.

save-the-text-document-from-txt-extension-to-bat-extension-to-save-the-batch-script-to-show-environment-variables-in-windows.webp

File Extension from “.txt” to “.bat”

Step 5: Once the file is saved, double-click it to execute and you’ll see the environment variables listed in command prompt.

running-batch-script-to-show-environment-variables-in-windows.webp

Running Batch Script To Show Environment Variables

NOTE: If copying and pasting the script above doesn’t work, type the script in the text document instead.

5. Check Environment
Variables using System Information

Step 1: In the Start menu, search for System Information and open it or press the “Windows Logo Key + R” key combination to open Windows Run, type “msinfo32” (without quotation marks) and hit the enter key.

system-information-app-icon-in-windows.webp

System Configuration Icon

Step 2: In the left sidebar, expand the “Software Environment” section by clicking the “+” icon, click the environment variables button and you’ll see the environment variables listed on the right pane.

click-the-plus-button-to-expand-the-software-tab-and-click-the-environment-variables-button.webp

“+” Button > “Environment Variables” Button

6. Check Environment
Variables using Registry Editor

1. Check
System Environment Variables using Registry Editor

Step 1: In the Start menu, search for Registry Editor and hit the enter key or press the “Windows Logo Key + R” key combination on the keyboard, type: regedit and hit the enter key.

Step 2: To Check System Variables, navigate to the following path: Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment and you’ll find the system variables listed on the right pane.

check-system-environment-variables-in-windows-using-registry-editor.webp

System Environment Variables in Registry Editor

2.
Check Environment Variables for Current User using Registry Editor

Step 1: In the Start menu, search for Registry Editor and hit the enter key or press the “Windows Logo Key + R” key combination on the keyboard, type: regedit and hit the enter key.

Step 2: To check user variables, navigate to the following path: Computer\HKEY_CURRENT_USER\Environment and you’ll find the user variables listed on the right pane.

check-user-environment-variables-in-windows-using-registry-editor.webp

User Environment Variables in Registry Editor

FAQs Related to
Environment Variables

How does environment
variables work in Windows?

Environment variables are the dynamic objects in form of key/value pairs that are responsible for instructing the programs to search for user profile settings, install files, and store temporary files in appropriate location in Windows.

What are types of
environmental variables?

There are two types of environment variables: User environment variables and system environment variables. The system variables are shared and applied to all users on the computer, but the user variables are exclusive to each profile.

Where are
environment variables stored in Windows?

In Windows, the user environment variables are stored in HKEY_CURRENT_USER\Environment in the registry editor and the system variables are stored in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment in the registry editor.

Next
Steps

We’ve covered how to check environment variables in Windows 11. To list environment variables in Windows, you can use any one of the methods listed above.

Further, configure the environment variables and other settings by referring the related articles below.

You can view environment variables in the Command Prompt by using the `set` command, which lists all environment variables in the current session. Here’s how to do it:

set

What Are Environment Variables?

Environment variables are dynamic values that the operating system uses to determine how to behave in different circumstances. They serve as a list of key-value pairs that can be used by various applications and scripts running on your computer.

There are two main types of environment variables:

  • User Variables: These are specific to the user account currently logged into the system. They can be tailored to individual user preferences and settings.

  • System Variables: These are global variables accessible to all users on the machine. They define system-wide configurations, such as the path where executable files are located.

Understanding environment variables is crucial for effectively managing software applications and system configurations, as they dictate various settings for the way programs operate.

Check Environment Variables in Cmd: A Quick Tutorial

Check Environment Variables in Cmd: A Quick Tutorial

Why You Might Want to View Environment Variables

Knowing how to view environment variables can be beneficial for several reasons:

  • Modifying System Paths: You might want to add or modify paths for executable files, allowing for quicker access to commands and scripts.

  • Configuring Software Applications: Some applications rely on environment variables for configurations, such as setting database connection strings or API keys.

By viewing environment variables, you can troubleshoot issues, optimize your workflows, and better understand how your system operates.

cmd Echo Environment Variable: Quick Start Guide

cmd Echo Environment Variable: Quick Start Guide

How to Check Environment Variables in Windows CMD

Using the `set` Command

The `set` command is one of the simplest ways to view environment variables within the Windows Command Prompt. When executed without any parameters, the command displays a complete list of all environment variables in your current session.

Syntax:

set

When you run this command, you’ll receive an output that looks something like this:

PATH=C:\Program Files\Java\jdk-11.0.11\bin;C:\Windows\system32;...
USERPROFILE=C:\Users\YourUsername

Each line shows a single environment variable and its current value.

Displaying a Specific Environment Variable

If you’re interested in viewing the value of a specific environment variable, you can use the `echo` command. This is particularly useful for checking the value of common variables like `PATH`.

Syntax:

echo %VARIABLE_NAME%

For example, to check the `PATH` variable, you would execute:

echo %PATH%

The output will display the directories listed in your `PATH`, enabling you to confirm whether the necessary directories are included for executable files.

How to Open Environment Variables from Cmd Easily

How to Open Environment Variables from Cmd Easily

Show Environment Variables CMD: A Detailed Breakdown

Listing All Environment Variables

If you’d like to scroll through the environment variables one page at a time, you can use the `more` command in conjunction with `set`. This technique helps you avoid overwhelming amounts of output in your Command Prompt window.

Code Snippet:

set | more

This command lists all environment variables but pauses for you to read each page, allowing for easier navigation through the output.

Viewing System vs. User Variables

Understanding the difference between user and system variables is essential when managing your environment. To see this distinction, you can use the `systeminfo` command.

Code Snippet:

systeminfo | findstr /i "environment"

The output from this command will include a summary of environmental variables and will help you differentiate between those set for the user and those available to the system. This is valuable when troubleshooting variable-related issues.

Mastering Variables in Cmd: A Quick Reference Guide

Mastering Variables in Cmd: A Quick Reference Guide

Show Environment Variables Windows CMD: GUI vs. Command Line

Accessing Environment Variables via GUI

Windows provides a graphical interface to access environment variables via the System Properties. You can navigate to Control Panel > System > Advanced system settings > Environment Variables. This view provides an organized way to edit or view variables.

While this method is user-friendly, it lacks the speed and efficiency of using the command line, especially for those who are experienced with CMD commands.

Advantages of Using CMD to Show Environment Variables

Using CMD offers distinct advantages:

  • Speed and Efficiency: Commands can quickly display or modify environment variables without navigating through multiple GUI windows.

  • Automation Capabilities: Commands can be scripted for batch processing, making repetitive tasks simpler and faster.

Delete Files Cmd: A Quick Guide to File Removal

Delete Files Cmd: A Quick Guide to File Removal

Troubleshooting Common Issues

Environment Variables Not Showing

If you find that expected environment variables are not showing in your CMD session, there could be several reasons. First, ensure that you are running the Command Prompt with sufficient permissions. Running as an administrator may be necessary for system-level variables.

Additionally, if you see unexpected output, it may be due to incorrect syntax or mistyping the variable name. Always check the correct casing and spelling of the variables.

Modifying Environment Variables through CMD

For those interested in making permanent changes to environment variables, the `setx` command can be employed. This command enables you to create or modify variables for future sessions.

Syntax:

setx VARIABLE_NAME "value"

For example, if you want to set a new user variable related to HTML files, you could run:

setx HTML_PATH "C:\html_files"

Keep in mind that changes made using `setx` will only apply to new Command Prompt sessions.

Mastering Cmd Set Variable: Quick Guide for Beginners

Mastering Cmd Set Variable: Quick Guide for Beginners

Understanding Environment Variables in Batch Scripting

Using Environment Variables in Scripts

Environment variables can significantly enhance the functionality of batch scripts. By incorporating them, you can customize script behavior based on user settings or system configurations.

For instance, you can use environment variables to specify a user directory dynamically:

@echo off
echo User directory is: %USERPROFILE%

This line will output the current user’s profile directory when the script is executed, allowing scripts to adapt to different users without hardcoding values.

Exploring Cmd System Variables: A Quick Guide

Exploring Cmd System Variables: A Quick Guide

Conclusion

Understanding how to view environment variables cmd is a fundamental skill for anyone looking to leverage the full capabilities of Windows. Whether you’re troubleshooting issues, fine-tuning your system’s performance, or scripting automation tasks, being able to confidently access and manage these variables is invaluable. With the commands and techniques discussed here, you are well on your way to mastering Windows Command Prompt and enhancing your workflow.

If you want to see or check the names and values of Environment Variables in Windows 11 or Windows 10, here is how you can do that. There are mainly four ways to find almost everything about the Environment Variables in Windows 11/10, and this article explains all the possible methods.

What are Environment Variables in Windows 11/10

Environment Variables contain some information related to WindowsApps path, currently logged-in user’s information, Temporary folder’s path, running processes, etc. Although Windows 11/10 comes with a few of those, you can add or modify Environment Variables in Windows PC easily.

However, if you want to find those Environment Variables in Windows 11 or Windows 10, this guide will be handy for you. As said earlier, there are four ways – using the Windows Settings panel, using Command Prompt, using the Registry Editor, and using Windows PowerShell.

To see the names and values of Environment Variables in Windows 11/10, follow these methods:

  1. Using Windows Settings panel
  2. Using Command Prompt
  3. Using Registry Editor
  4. Using Windows PowerShell

To learn more about these steps, continue reading.

1] Using Windows Settings panel

How to see Names and Values of Environment Variables in Windows 11/10

It is the most common method to find the names and values of the Environment Variables in Windows 11/10 PC. Earlier, it was possible to do the same using Control Panel. However, if you are using Windows 11, there is no need to go through the Control Panel since it will eventually open the Windows Settings.

Follow these steps to find the Environment Variables:

  • Press Win+I to open Windows Settings.
  • Go to System > About.
  • Click on the Advanced system settings.
  • Click the Environment Variables button.
  • Find the Environment Variables.

Next, you need to click on each variable to find the details. It displays a detailed list in the System variables box.

2] Using Command Prompt

How to see Names and Values of Environment Variables in Windows 11/10

It is probably the easiest method to find almost everything about the Environment Variables on Windows 11/10 PC. For this purpose, we are going to use the Command Prompt instance in Windows Terminal. However, you can open the standalone Command Prompt window and enter the following command:

set

In case you do not know the process to open the Windows Terminal, you can press Win+X and select the Windows Terminal from the WinX menu.

3] Using Registry Editor

How to see Names and Values of Environment Variables in Windows 11/10

If you do not want to do much with the Environment Variables and want to check them only, you can use the Registry Editor. As these variables depend on the user profile, you need to open the HKEY_CURRENT_USER. To find the names and values of the Environment Variables using Registry Editor, do the following:

  • Press Win+R to open the Run prompt.
  • Type regedit and hit the Enter button.
  • Click on the Yes button in the UAC prompt.
  • Navigate to this path: HKEY_CURRENT_USER\Environment
  • Find the variables.

In case you want to modify the existing variables using Registry Editor, you need to double-click on each of them and change them according.

4] Using Windows PowerShell

How to see Names and Values of Environment Variables in Windows 11/10

Like, Command Prompt, you can use Windows PowerShell to find the same Environment Variables on your Windows 11 or Windows 10 computer. However, it displays all the Environment Variables of all the users, whereas other methods display only the current user’s variables. That being said, the list could be lengthy since it may contain some variables, such as ComSpec, LOCALAPPDATA, HOMEDRIVE, HOMEPATH, ALLUSERSPROFILE, etc.

If you are fine with the lengthy list, you can use Windows PowerShell and enter this command:

dir env:

Like the Command Prompt method, you can open the standalone Windows PowerShell or the PowerShell instance in the Windows Terminal.

How do I view Environment Variables in Windows 11?

To view the Environment Variables in Windows 11, you can use any of the aforementioned methods. If you do not want to modify existing variables, you can use the Command Prompt method. For that, you can open the Command Prompt or the Command Prompt instance in Windows Terminal and enter this command: set. Then, it displays almost everything about the current user’s Environment Variables on your screen. Similarly, you can use the Windows PowerShell method to get the same thing done. In that case, you have to use this command: dir env:

How do I get a list of Environment Variables?

To get a list of Environment Variables, you have four techniques in your hands. However, using the Windows Settings method is probably the most fruitful method since you can view, add, or modify any Environment Variable without any issue. However, if you want to get a list only, you can use any of the other three methods. To choose one, you can open the Windows Terminal and enter this command in the PowerShell instance: dir env:. If you want to use the Command Prompt instance, you need to execute this command: set.

That’s all! Hope this guide helped.

Read: How to add or edit a PATH Environment Variable in Windows.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Как зайти в домашнюю группу windows 10
  • На этот диск невозможно установить windows так как gpt
  • Asrock a55m hvs драйвера windows 10
  • Wmp11 for windows 7
  • Dawn of war ii chaos rising games for windows live