Windows user home environment variable

To be clear, I’m not asking can it be set or how to set it, I’m asking is it already set at all on a new copy of Windows. The ideal way to find this out would be to install a fresh copy of Windows on a VM and check, since most of everybody who can answer this question will already have it set ;-)

I need to know if I can depend on it always being there. (I understand that these can be unset, but if you know how to do that you know you’re asking for trouble.)

asked Jun 13, 2013 at 11:12

Sean Allred's user avatar

No, it is not. The closest equivalents in Windows NT are %UserProfile% and %HomeDrive%%HomePath% (note that they may point to different locations – the profile is always local, while the home can point to a network share).

answered Jun 13, 2013 at 11:19

u1686_grawity's user avatar

u1686_grawityu1686_grawity

430k64 gold badges899 silver badges973 bronze badges

2

No.

The equivalent environment variables that are set are HOMEDRIVE and HOMEPATH.

answered Jun 13, 2013 at 11:20

Oliver Salzburg's user avatar

Oliver SalzburgOliver Salzburg

86.6k63 gold badges261 silver badges306 bronze badges

There’s also %LOCALAPPDATA% (never roaming) and %APPDATA% (can roam). You’re not supposed to write to %UserProfile% directly, and you can’t predict the relative path from %LOCALAPPDATA% to %APPDATA% (could be localized).

answered Jun 13, 2013 at 18:47

MSalters's user avatar

MSaltersMSalters

8,1851 gold badge23 silver badges29 bronze badges

1

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

To be clear, I’m not asking can it be set or how to set it, I’m asking is it already set at all on a new copy of Windows. The ideal way to find this out would be to install a fresh copy of Windows on a VM and check, since most of everybody who can answer this question will already have it set ;-)

I need to know if I can depend on it always being there. (I understand that these can be unset, but if you know how to do that you know you’re asking for trouble.)

asked Jun 13, 2013 at 11:12

Sean Allred's user avatar

No, it is not. The closest equivalents in Windows NT are %UserProfile% and %HomeDrive%%HomePath% (note that they may point to different locations – the profile is always local, while the home can point to a network share).

answered Jun 13, 2013 at 11:19

u1686_grawity's user avatar

u1686_grawityu1686_grawity

430k64 gold badges899 silver badges973 bronze badges

2

No.

The equivalent environment variables that are set are HOMEDRIVE and HOMEPATH.

answered Jun 13, 2013 at 11:20

Oliver Salzburg's user avatar

Oliver SalzburgOliver Salzburg

86.6k63 gold badges261 silver badges306 bronze badges

There’s also %LOCALAPPDATA% (never roaming) and %APPDATA% (can roam). You’re not supposed to write to %UserProfile% directly, and you can’t predict the relative path from %LOCALAPPDATA% to %APPDATA% (could be localized).

answered Jun 13, 2013 at 18:47

MSalters's user avatar

MSaltersMSalters

8,1851 gold badge23 silver badges29 bronze badges

1

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

Переменная среды (environment variable) — текстовая короткая ссылка на элемент операционной системы Windows, предназначенная для получения быстрого доступа к объекту системы, или к данным о каталогах и конфигурации компьютера. Переменная среды (переменная окружения) позволяет быстро перейти к нужному месту на компьютере, без использования имени пользователя или полного пути к объекту.

Переменные окружения Windows используются в командной строке, в диалоговом окне «Выполнить» и адресной строке Проводника. Переменная среды может содержать информацию о настройках системы или данные о текущем пользователе компьютера.

Содержание:

  1. Пример использования переменной среды Windows
  2. Как посмотреть переменные среды Windows 10
  3. Доступ к переменным средам из реестра Windows
  4. Как посмотреть все переменные среды в командной строке
  5. Открытие списка переменных среды в Windows PowerShell
  6. Создание переменной среды в Windows
  7. Список переменных среды Windows в таблице
  8. Выводы статьи

Переменные среды Windows делятся на два вида:

  • Пользовательские переменные среды — содержат указания пути к пользовательским каталогам.
  • Системные переменные среды — содержат информацию о каталогах ОС и конфигурации ПК.

Чаще всего переменные среды используются как путь к дискам, файлам или параметрам системы. Использование переменной среды позволяет быстро перейти к нужной директории операционной системы, без ввода полного пути, например, без ввода имени пользователя.

Переменные окружения часто используются при написании скриптов, или при работе в командной строке. Короткие переменные можно использовать вместо полного пути до файла или папки, например, при создании ярлыков, при вводе пути к объекту.

Пример использования переменной среды Windows

Рассмотрим следующий пример: пользователю нужно открыть системную папку «AppData», в которой находятся различные данные программ, установленных в операционную систему Windows. Скрытая папка «AppData» находится в профиле пользователя, обычно на диске «C:». Данные приложений расположены по пути:

C:\Users\Имя_ пользователя\AppData\Roaming

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

При помощи переменной «%APPDATA%» (переменная используется без кавычек) можно сразу открыть нужную директорию в системе, без ввода имени пользователя, включения отображения скрытых папок, ввода полного пути. Это экономит много времени.

Чтобы открыть нужный каталог достаточно лишь ввести «%APPDATA%» в поле поиска Windows, в адресную строку Проводника или в диалоговое окно «Выполнить», а затем нажать на клавишу «Enter».

Переменные среды Виндовс заключены в специальный оператор «%», который находится с двух сторон названия переменной. Это необходимо, чтобы система могла обработать запрос.

Пользователь может самостоятельно создавать переменные среды или изменять существующие. В статье мы рассмотрим несколько способов просмотра переменных среды и самостоятельное создание переменной. В руководстве вы найдете таблицу со списком переменных, применяемых в операционных системах Windows 10, Windows 8.1, Windows 8, Windows 7.

Как посмотреть переменные среды Windows 10

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

Чтобы посмотреть переменные окружения Windows 10, выполните следующее:

  1. Нажмите на клавиши» «Win» + «R».
  2. В окне «Выполнить» введите команду: «systempropertiesadvanced» (без кавычек), а затем нажмите на кнопку «ОК».
  3. В окне «Свойства системы», во вкладке «Дополнительно» нажмите на кнопку «Переменные среды…».

переменные среды

  1. В окне «Переменные среды» отображаются пользовательские переменные среды и системные переменные среды.

переменные среды

Доступ к переменным средам из реестра Windows

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

Системные переменные среды находятся по следующему пути:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

переменное окружение в реестре

Переменные среды локального пользователя расположены в следующей ветке реестра:

HKEY_CURRENT_USER\Environment

перменные среды в реестре

Вы можете создать в редакторе реестра новые переменные или изменить существующие.

Как посмотреть все переменные среды в командной строке

Пользователь может получить список переменных среды при помощи системного инструмента — командной строки Windows.

В cmd переменные среды открываются следующим образом:

  1. Запустите командную строку от имени администратора.
  2. Выполните команду:
set

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

Для получения списка переменных в виде текстового файла, выполните в командной строке команду:

set > C:\Variables.txt

После выполнения этой команды, на Локальном диске «C:» появится текстовый файл с именем «Variables» (имя можно использовать любое), в котором находится список переменных среды Windows.

На моем компьютере файл имеет следующее содержание:

ALLUSERSPROFILE=C:\ProgramData

APPDATA=C:\Users\User\AppData\Roaming

CommonProgramFiles=C:\Program Files\Common Files

CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files

CommonProgramW6432=C:\Program Files\Common Files

COMPUTERNAME=DESKTOP-3HEECRJ

ComSpec=C:\WINDOWS\system32\cmd.exe

DokanLibrary1=C:\Program Files\Dokan\DokanLibrary-1.2.2\

DriverData=C:\Windows\System32\Drivers\DriverData

HOMEDRIVE=C:

HOMEPATH=\Users\User

LOCALAPPDATA=C:\Users\User\AppData\Local

LOGONSERVER=\\DESKTOP-3HEECRJ

NUMBER_OF_PROCESSORS=4

OneDrive=C:\Users\User\OneDrive

OneDriveConsumer=C:\Users\User\OneDrive

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\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\User\AppData\Local\Microsoft\WindowsApps

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

PROCESSOR_ARCHITECTURE=AMD64

PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 60 Stepping 3, GenuineIntel

PROCESSOR_LEVEL=6

PROCESSOR_REVISION=3c03

ProgramData=C:\ProgramData

ProgramFiles=C:\Program Files

ProgramFiles(x86)=C:\Program Files (x86)

ProgramW6432=C:\Program Files

PROMPT=$P$G

PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

PUBLIC=C:\Users\Public

SystemDrive=C:

SystemRoot=C:\WINDOWS

TEMP=C:\Users\User\AppData\Local\Temp

TMP=C:\Users\User\App\Data\Local\Temp

TMPDIR=C:\Users\Public\Documents\Wondershare\Creator\Temp

USERDOMAIN=DESKTOP-3HEECRJ

USERDOMAIN_ROAMINGPROFILE=DESKTOP-3HEECRJ

USERNAME=User

USERPROFILE=C:\Users\User

windir=C:\WINDOWS

Открытие списка переменных среды в Windows PowerShell

Открытие списка переменных среды возможно при помощи системного средства Windows PowerShell.

Выполните следующие действия:

  1. Запустите Windows PowerShell от имени администратора.
  2. Введите команду, а затем нажмите на клавишу «Enter»:
dir Env:
  1. В окне PowerShell откроется список переменных среды Windows.

переменные среды в powershell

Создание переменной среды в Windows

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

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

Проделайте следующее:

  1. В окне «Переменные среды» выберите одну из групп переменных: пользовательские или системные переменные.
  2. Нажмите на кнопку «Создать…».

переменные среды

На этом примере я создам отдельную переменную среды для запуска программы TeamViewer.

  1. В окне «Изменение пользовательской переменной» добавьте имя переменной, а в поле «Значение переменной:» введите полный путь к исполняемому файлу.

изменение переменной

  1. В окне переменных сред добавилась новая переменная. Нажмите на кнопку «ОК» для применения изменений.

переменная создана

  1. В диалоговом окне «Выполнить» введите «%Имя_переменной%», в нашем случае, «%TeamViewer%», нажмите на кнопку «ОК».

выполнить

  1. На Рабочем столе компьютера откроется окно запущенной программы.

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

Переменная среды пути «Path» содержит список директорий на компьютере, в которых система должна искать исполняемые файлы. Переменная среды пути «PATH» не добавляется к исполняемым файлам, а только к директориям, где находятся данные файлы.

Если добавить в переменную среды Path Windows путь к директории с исполняемым файлом, например, для браузера Google Chrome: C:\Program Files (x86)\Google\Chrome\Application, то программа запустится из командной строки, после выполнения команды «chrome», без ввода полного пути к исполняемому файлу.

добавление переменной

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

Список переменных среды Windows в таблице

Для удобства посетителей сайта я собрал в общую таблицу переменные, их описание и значения в операционной системе Windows. В подавляющем большинстве случаев, системная папка расположена на диске «C:», поэтому пути в значениях даны для этого диска.

Переменная Назначение Значение переменной
%ALLUSERSPROFILE% Папка ProgramData C:\ProgramData
%APPDATA% Папка размещения данных программ C:\Users\User\AppData\Roaming
%CommonProgramFiles% Папка Common Files в Program Files C:\Program FilesCommon Files
%CommonProgramW6432% Папка Common Files в Program Files C:\Program Files\Common Files
%COMPUTERNAME% Имя компьютера DESKTOP-XXXXXXX
%ComSpec% Запуск командной строки C:\WINDOWS\system32\cmd.exe
%DriverData% Папка DriverData C:\Windows\System32\Drivers\DriverData
%HOMEDRIVE% Системный диск C:
%HOMEPATH% Папка профиля пользователя C:\Users\User
%LOCALAPPDATA% Папка локальных данных приложений C:\Users\User\AppData\Local
%LOGONSERVER% Имя контроллера домена \DESKTOP-XXXXXXX
%NUMBER_OF_PROCESSORS% Количество потоков процессора
%OneDrive% Папка OneDrive C:\Users\User\OneDrive
%Path% Путь поиска исполняемых файлов C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;…
%PATHEXT% Исполняемые расширения файлов .COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS; .JSE; .WSF; .WSH; .MSC
%PROCESSOR_ARCHITECTURE% Архитектура процессора AMD64; x86; IA64
%PROCESSOR_IDENTIFIER% Описание процессора
%PROCESSOR_LEVEL% Номер модели процессора
%PROCESSOR_REVISION% Ревизия процессора
%ProgramData% Папка ProgramData C:\ProgramData
%ProgramFiles% Папка ProgramFiles C:\Program Files
%ProgramFiles(x86)% Папка ProgramFiles(x86) C:\Program Files (x86)
%ProgramW6432% Папка ProgramFiles C:\Program Files
%PROMPT% Возвращение параметров командной строки
%PSModulePath% Пути к расположению модулей PowerShell C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
%PUBLIC% Папка «Общие» в профиле пользователей C:\Users\Public
%SystemDrive% Системный диск с Windows C:
%SystemRoot% Папка Windows C:\Windows
%TEMP% Временный каталог C:\Users\User\AppData\Local\Temp
%TMP% Временный каталог C:\Users\User\AppData\Local\Temp
%USERDOMAIN% Имя домена DESKTOP-XXXXXXX
%USERNAME% Имя пользователя User
%USERPROFILE% Профиль пользователя C:\Users\User
%Windir% Папка Windows C:\Windows

Выводы статьи

Переменные окружения Windows позволяют пользователю экономить время во время работы на компьютере. Переменными средами Windows могут пользоваться обычные пользователи или системные администраторы для быстрого доступа к объектам операционной системы, чтобы открыть нужную директорию на компьютере, или запустить программу.

Похожие публикации:

  • Некоторыми параметрами управляет ваша организация в Windows 10
  • Как закрепить папку на панели задач Windows 10 — 5 способов
  • Как создать загрузочную флешку Windows 7 — 5 способов
  • Как удалить программу в Windows 10 — 9 способов
  • Оптимизация Windows 10 для ускорения работы ПК

Most operating systems have environment variables, including Windows, MacOS, and Linux. Just like in a programming language, environment variables can be called upon to use their values that can store a number, a location, or any other value defined.

The environment variables were introduced with Windows 95, and have since gone through many iterations with every Windows release. These can be used to access certain directories quickly, rather than enter the complete paths.

Environment variables can be edited and manipulated, or you can even add new ones. In this article, we discuss the many different Windows environment variables and what they do, and all that you need to know about them.

This guide applies to all versions of Windows, including Windows XP, Windows Vista, Windows 7, Windows 8, Windows 10, and Windows 11.

Table of contents

  • What are Environment Variables
  • What are Environment Variable Scopes
    • System/Machine
    • User
    • Process
  • Complete list of Windows Environment Variables
  • Where are Environment Variables Stored
  • How to View/Access Windows Environment Variables
    • Access Environment Variables from Settings App
    • Access Environment Variables from Command Line
    • List Environment Variables in PowerShell
    • View Value for Environment Variable using Command Prompt
  • How to Create and Set Environment Variables in Windows
    • From System Properties
    • From Command Prompt
      • Temporary Environment Variable
      • Permanent Environment Variable
  • How to Delete an Environment Variable in Windows
  • How to Edit an Environment Variable in Windows
  • What is the PATH Environment Variable
  • How to Manage Environment Variables using PowerShell Env
  • Frequently Asked Questions (FAQs)
    • Is it safe to delete an environment variable?
    • What does the PATH environment variable do?

What are Environment Variables

Environment variables are variables that can be used across your system. Just like in programming, variables contain a value that can be changed or called when needed. Environment variables are the same, but can be used across the entire scope.

You can use environment variables in Windows to store frequently used locations, so you don’t have to type them out each time, or temporarily change the way a program behaves. Environment variables are normally used in scripts or programs/apps.

For example, you can create an environment variable called TEMP that points to a different folder than the default TEMP folder Windows uses. Then, when a program needs to store temporary files, it will use the TEMP folder you specified instead of the default one.

Tip: If you are using Linux or MacOS, the environment variables can be set in the .bashrc or .profile files.

There are 3 types/scopes of environment variables in the hierarchy:

  1. Machine
  2. User
  3. Process

At the top, you have machine or system environment variables. This can be used across the entire system, regardless of which user is logged in. Then there are user environment variables. This is defined individually for each user account and is limited to that account only.

Then you have the process variables which are only limited to the processes and cannot be edited or created. The end-user does not see or have anything to do with the process variables.

Additionally, if there is an environment variable of the same name in more than one scope, then the variable in the lower scope will supersede the value of the one higher in the hierarchy.

For example, the common environment variable “TEMP” is available in all scopes with the following values:

  • Machine: C:\Windows\Temp
  • User: C:\Users\[Username]\AppData\Local\Temp
  • Process: C:\Users\[Username]\AppData\Local\Temp

Hence, using the “Temp” variable will call for the value set for the process scope. If there is no variable by the name “Temp” in this scope, then it will use the value for the user scope, and so on.

You can use these variables to access a directly quickly. For example, typing in “%HOMEPATH%” in the Run Command box will open the user’s home directory.

homepath variable

Using an environment variable

You can also edit this variable to include a sub-directory of the path, like opening the user account’s desktop by typing in “%HOMEPATH%\Desktop%”.

homepath desktop variable

Using an environment variable to open its subdirectory

What are Environment Variable Scopes

As we mentioned earlier, there are 3 scopes for environment variables: Machine/System, user, and process. These scopes define the limitations of the variables and where they can be used.

Below you’ll find a more detailed explanation of the different types of environment variable scopes.

System/Machine

The environment variables defined inside this scope can be used by anyone on the system. These types of variables are associated with the running instance of Windows. Any user account can read these, set, change, or delete them, provided they have administrative rights.

User

The environment variables defined within this scope are only user-specific and might be different for each user account. This is associated with the current user. User variables overwrite machine-scoped variables with the same name.

Process

Environment variables in this scope are a combination of machine and user scopes in addition to some dynamically-created variables by the Windows OS.

Now that you know what environment variables are and how they work, let us see which variables are available in a Windows OS.

Here is a list of the process variables which are available in this scope:

  • ALLUSERSPROFILE
  • APPDATA
  • COMPUTERNAME
  • HOMEDRIVE
  • HOMEPATH
  • LOCALAPPDATA
  • LOGONSERVER
  • PROMPT
  • PUBLIC
  • SESSION
  • SystemDrive
  • SystemRoot
  • USERDNSDOMAIN
  • USERDOMAIN
  • USERDOMAIN_ROAMINGPROFILE
  • USERNAME
  • USERPROFILE

Complete list of Windows Environment Variables

Below is a complete list of the environment variables that you will find inside the Windows operating system by default:

Windows Environment Variables Opt

Default Windows Environment Variables
Variable Name Value
%ALLUSERSPROFILE% C:\ProgramData
%APPDATA% C:\Users\{username}\AppData\Roaming
%COMMONPROGRAMFILES% C:\Program Files\Common Files
%COMMONPROGRAMFILES(x86)% C:\Program Files (x86)\Common Files
%CommonProgramW6432% C:\Program Files\Common Files
%COMSPEC% C:\Windows\System32\cmd.exe
%HOMEDRIVE% C:\
%HOMEPATH% C:\Users\{username}
%LOCALAPPDATA% C:\Users\{username}\AppData\Local
%LOGONSERVER% \\{domain_logon_server}
%PATH% C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
%PathExt% .com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.msc
%PROGRAMDATA% C:\ProgramData
%PROGRAMFILES% C:\Program Files
%ProgramW6432% C:\Program Files
%PROGRAMFILES(X86)% C:\Program Files (x86)
%PROMPT% $P$G
%SystemDrive% C:
%SystemRoot% C:\Windows
%TEMP% C:\Users\{username}\AppData\Local\Temp
%TMP% C:\Users\{username}\AppData\Local\Temp
%USERDOMAIN% Userdomain associated with the current user.
%USERDOMAIN_ROAMINGPROFILE% Userdomain associated with roaming profile.
%USERNAME% {username}
%USERPROFILE% C:\Users\{username}
%WINDIR% C:\Windows
%PUBLIC% C:\Users\Public
%PSModulePath% %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\
%OneDrive% C:\Users\{username}\OneDrive
%DriverData% C:\Windows\System32\Drivers\DriverData
%CD% Outputs current directory path. (Command Prompt.)
%CMDCMDLINE% Outputs command line used to launch current Command Prompt session. (Command Prompt.)
%CMDEXTVERSION% Outputs the number of current command processor extensions. (Command Prompt.)
%COMPUTERNAME% Outputs the system name.
%DATE% Outputs current date. (Command Prompt.)
%TIME% Outputs time. (Command Prompt.)
%ERRORLEVEL% Outputs the number of defining exit status of the previous command. (Command Prompt.)
%PROCESSOR_IDENTIFIER% Outputs processor identifier.
%PROCESSOR_LEVEL% Outputs processor level.
%PROCESSOR_REVISION% Outputs processor revision.
%NUMBER_OF_PROCESSORS% Outputs the number of physical and virtual cores.
%RANDOM% Outputs random numbers from 0 through 32767.
%OS% Windows_NT
List of all Windows Environment Variables

Where are Environment Variables Stored

The environment variables are stored in 2 places in the Windows Registry; one for the system and one for individual users.

The system environment variables are stored at the following location:

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

System environmental variables in Windows Registry

System environment variables in Windows Registry

The user environment variables are stored at the following location:

Computer\HKEY_CURRENT_USER\Environment

User environmental variables in Windows Registry

User environment variables in Windows Registry

You can also export the “Environment” key using its context menu to import the environment variables on another Windows computer, or vice versa.

Now that you know where they are stored, you may have a look at them. However, it is strongly recommended that you do not add or change environment variables using the Windows Registry. This is because any running processes will not see variable changes in the registry. Processes only see the registry variables and values that are present when the process was started unless Windows notifies them that there has been a change.

If you want to add or make changes to the environment variables, keep reading this post.

How to View/Access Windows Environment Variables

You can view and access Windows environment variables in multiple ways. Pick the method you like best from below.

Access Environment Variables from Settings App

Follow these steps to access the environment variables using the Settings app:

  1. Navigate to the following:

    Settings app >> System >> About
  2. Now click Device Specifications to expand it.

    Expand Device Specifications

    Expand Device Specifications
  3. Now click Advanced system settings under Related links.

    Open Advanced system settings

    Open Advanced system settings
  4. From the pop-up System Properties window, switch to the Advanced tab, and then click Environment Variables.

    Open Environmental Variables

    Open Environment Variables
  5. The Environment Variables window will now open. Here, you can see the user variables at the top and the system/machine variables at the bottom.

    Environmental Variables window

    Environment Variables window

Access Environment Variables from Command Line

If you want to access the environment variables using the Command Line, here is how:

  1. Run the following cmdlet in either the Command Prompt, Windows PowerShell, or the Run Command box to open the System Properties applet.

    sysdm.cpl

    sysdm

    Open System Properties applet
  2. From the pop-up System Properties window, switch to the Advanced tab, and then click Environment Variables.

    Open Environmental Variables2

    Open Environment Variables
  3. The Environment Variables window will now open. Here, you can see the user variables at the top and the system/machine variables at the bottom.

    Environmental Variables window2

    Environment Variables window

List Environment Variables in PowerShell

Alternative to the methods discussed above, you can also list the environment variables in PowerShell using a simple cmdlet.

Run the following command in an elevated PowerShell instance and it will display all of the environment variables on your computer:

Get-ChildItem Env: | Sort Name

List environmental variables in PowerShell

List environment variables in PowerShell

View Value for Environment Variable using Command Prompt

If you access the environment variable using any of the given methods above, then you can see their values as well. Another method to view the value of an environment variable is through the Command Prompt.

Simply type in “echo” followed by the environment variable name in the “%” sign in an elevated Command Prompt and you will then see its value(s), as in this image:

Display environment variable value

Display environment variable value

How to Create and Set Environment Variables in Windows

From System Properties

You may need to create a new environment variable or modify an existing one in the Windows OS to be used for programming purposes or to use Java. Whatever the reason, follow these steps to create a new environment variable using the GUI:

  1. Access the Environment Variables window using one of the given methods above. In this window, click New either under user variables or system variables, depending on which scope you want to create the variable in.

    Create a new varibale

    Create a new variable
  2. In the popup window, set a name for the variable and then enter its value. Once done, click Ok.

    Enter details for variable

    Enter details for variable
  3. Back in the Environment Variable window, click OK again to save the changes.

The variable will now be created, and you can now use it in your code, or access the folder by concatenating a “%” sign on the front and back of it.

Access path using environmental vairable

Access path using environment variable

From Command Prompt

You can also create a new environment variable using the Command Prompt, and define its value(s). You can create both a temporary variable that only lasts until the instance is closed or the system is rebooted, or a permanent variable that will always remain unless explicitly deleted.

Once you create the variable, you can access it immediately. There’s no need to restart the computer for the changes to take effect.

Note: These methods create a user environment variable and not a system variable.

Temporary Environment Variable

Use the following cmdlet in an elevated Command Prompt to create a temporary variable while replacing [VariableName] with a custom name for the variable, and [Value] with the value that you want to define for the variable, which can be a string or a number.

Set [VariableName]=[Value]

Create new environment variable using Command Prompt

Create new environment variable using Command Prompt

Permanent Environment Variable

If you want to create a permanent environment variable, then use this cmdlet instead:

Setx [VariableName] "[Value]"

Permanent variable created using Command Prompt

Permanent variable created using Command Prompt

How to Delete an Environment Variable in Windows

If you no longer need an environment variable, you can simply delete it.

One concern while deleting a variable is whether it is safe. The answer is both yes and no. Nothing happens when an environment variable is deleted, except that the apps, program, and other elements no longer know where to look for an item when it is called upon. Other than that, it has no impact on the system’s performance.

That said, we still think that you should be extremely careful when deleting a variable. If you still wish to continue to remove an environment variable, follow these steps:

Note: It is advisable that you create a system restore point before proceeding so that your system can be reverted to previous settings in case things do not go as planned.

  1. Access the Environment Variables window using one of the given methods above.

  2. In the Environment Variables window, click on the variable that you want to remove and click Delete under the same section.

    Delete environmental variable

    Delete environment variable
  3. Now click Ok to save the changes.

The variable will now be removed from your PC.

How to Edit an Environment Variable in Windows

You can also edit an environment variable. Its name can be changed as well as its value. However, it is recommended that you do not edit the default Windows environment variables, or else the apps and programs using those variables might no longer work.

That said, the “PATH” variable stores several paths to directories for executable files. You can safely add more directory paths to this variable without causing an issue.

Follow these steps to edit an environment variable in Windows:

  1. Access the Environment Variables window using one of the given methods above.

  2. Here, click on the variable that you want to edit and then click Edit under the same section.

    Edit an environmental variable

    Edit an environment variable
  3. From the Edit popup, make the changes you want to the name or the value of the variable, and then click Ok.

    Edit variable details

    Edit variable details
  4. Back on the Environment Variables window, click Ok to save the changes.

What is the PATH Environment Variable

Earlier in this post, we mentioned the PATH environment variable. The PATH variable is perhaps the most-used variable out of the lot.

The PATH variable stores multiple entries (or values). Those values specify the directories in which the executable programs are located on the system so that they can be started without knowing and typing the whole path to the file on the command line.

How to Manage Environment Variables using PowerShell Env

The PowerShell has a virtual drive known as the “PS Drive.” It is a data store location that you can access like a file system drive in Windows PowerShell. Using this drive, we can manage different aspects of the environment variables. A PS drive allows you to treat environment variables as if they are a file system through the Env: drive.

Below you’ll find the guidelines to perform different variables-related tasks using the Env: drive.

To begin, you must first switch to the ENv: drive. To do that, type in the following in the PowerShell window.

cd Env:

Enter the Env drive

Enter the Env: drive

To get the complete list of environment variables and their values, use the following cmdlet:

Get-Item -Path Env:

Get complete list of variables in Env

Get complete list of variables in Env

You can also create new environment variables from the Env: drive by using this cmdlet. Replace [VarableName] with a name for the variable, and [Value] with the value you want to set for the variable.

NewItem -Path Env:\[VariableName] -Value [Value]

Create a new variable in Env drive

Create a new variable in Env: drive

To set the value of an existing variable, use this cmdlet:

Set-Item -Path Env:[VariableName] -Value "[Value]"

Set change variable value in Env drive

Set/change variable value in Env drive

To delete an environment variable from the Env: drive, use this cmdlet:

Remove-Item -Path Env:\[VariableName]

Delete variable in Env Drive

Delete variable in Env Drive

Frequently Asked Questions (FAQs)

Is it safe to delete an environment variable?

The answer is both yes and no. Although deleting a default OS environment variable will have no performance repercussions, any apps or programs using that variable will no longer be able to look for the executables in the specified directories, or you won’t be able to use the shortcuts anywhere in the system to run an executable.

What does the PATH environment variable do?

The PATH environment variable can store multiple path values for different executable files. When an executable file is called, like “CMD,” the PATH variable tells it where to look for the cmd.exe file.

Windows environment variables are commonly-used short-cut commands to open a folder path in Windows. Whether you want to locate specific folders or troubleshoot a bug, you can perform these tasks quickly by typing environment variables in the Run menu or Command Prompt. The following is a complete list of system and user environment variables in Windows 10 and Windows 11.

Content

  • What Are Windows Environment Variables?
  • How to Access Environment Variables in Windows
  • System vs. User Environment Variables
  • 1. %AppData% and %LocalAppData%
  • 2. %CD%
  • 3. %CommonProgramFiles%
  • 4. %COMSPEC%
  • 5. %Date% or %Time%
  • 6. %DriverData%
  • 7. %HomeDrive%
  • 8. %LogOnServer%
  • 9. %Number_Of_Processors%
  • 10. %OneDrive%
  • 11. %OS%
  • 12. %Path%
  • 13. %PathExt%
  • 14. %Processor_Architecture%
  • 15. %Processor_Identifier%
  • 16. %Processor_Level%
  • 17. %Processor_Revision%
  • 18. %ProgramData%
  • 19. %ProgramFiles%
  • 20. %Prompt%
  • 21. %PSModulePath%
  • 22. %Public%
  • 23. %Random%
  • 24. %SessionName%
  • 25. %SystemRoot%
  • 26. %Temp%
  • 27. %UserDomain%
  • 28. %UserProfile%
  • 29. %WinDir%
  • 30. %ZES_ENABLE_SYSMAN%
  • Frequently Asked Questions

Also read: Windows 11 Search Bar Not Working? Here’s 9 Ways to Fix It

Environment variables in Windows are commands that launch a folder path using a brief text string within percent sign characters (%). The «environment» here refers to the runtime in which a program is executed. In fact, the purpose of these commands is to impact various running processes on your computer.

Popular environment variable examples are «%AppData%,» «DriverData%,» «%temp%,» and «%WinDir%.» You may have used them in Run menu or Command Prompt without actually knowing that they’re called environment variables.

Also read: 7 Easiest Ways to Access Blocked Websites

How to Access Environment Variables in Windows

It’s very easy to check all the environment variables present on a Windows device.

  1. Launch «View advanced system settings» using the Search button (magnifying glass) in Windows.
List Environment Variables View Advanced System Settings
  1. Alternatively, open Settings using  Win +  I, tap on «System -> About -> Advanced system settings.»
  2. Go to the «Advanced» tab and click «Environment Variables» under «Startup and Recovery.»
List Environment Variables Accessing Environment Variables Windows11

System vs. User Environment Variables

From the above menu option, you can see all the default/standard environment variables in one place. These are further classified into two categories:

  • User environment variables: these refer to user-centric file and folder paths. You can add shortcuts to any program you use, such as OneDrive, Microsoft Office, an Xbox PC app, and more and can freely edit and even delete the contents of the user environment variables.
  • System environment variables: these are the system-centric file and folder paths. While you can add new system environment variables (only if missing). Do not edit or delete the existing ones, as that may harm your device.
List Environment Variables What Are Environment Variables

Also read: How to Convert Legacy BIOS to UEFI in Windows

1. %AppData% and %LocalAppData%

%AppData% points toward the AppData Roaming folder that is connected to your Windows user profile. Roaming means that your user login information can be transferred from one Windows device to another. In contrast, %LocalAppData% opens local user profile folders created on a Windows PC.

Uses

  • Locating and clearing unnecessary files, settings, and data accumulating in AppData folders.
  • Admin user taking back full ownership of important system and registry files from TrustedInstaller.
List Environment Variables Appdata Windows11

2. %CD%

CD (change directory) is a common text string used to switch directory paths in Windows Command prompt and PowerShell. Thus, the %CD% variable tells you the precise execution directory in which you are running your code.

Uses

  • After scrolling through several lines of text in Command Prompt, it’s easy to forget which is the current working directory. Typing echo %CD% gives you the current one.
  • If running multiple Command prompts at once, %CD% saves you the trouble of identifying the correct working directory.
List Environment Variables Cd Command Windows11

3. %CommonProgramFiles%

The %CommonProgramFiles% variable refers to a Windows directory named «Common Files.» It contains many types of 64-bit files and folders shared among various apps. Another related variable, %CommonProgramFiles(x86)%, does the same job but for x86-based (32-bit) programs and utilities only.

Uses

  • The variable opens a sub-directory where you can view all of the files shared by separately-installed programs.
  • For any program, you can access common components present in both 64-bit and 32-bit folders. These include frameworks, Services, and DLL files.
List Environment Variables Common Program Files Windows11

Also read: How to Safely Bypass the TPM 2.0 Requirement in Windows 11

4. %COMSPEC%

%COMSPEC% or %ComSpec% is a shortcut text entry used in the Run menu to open the Command Prompt. It uniquely displays the entire Command Line path «C:\Windows\System32\Cmd.exe» on the window title.

Uses

  • Engage with the Command Line directly from any location on your PC.
  • If you’re running a computer with no hard disk, you can boot the device by launching CMD along with a configured RAM disk and USB drive.
List Environment Variables Comspec Windows11

5. %Date% or %Time%

As the name suggests, the environment variables %Date% and %Time% are used to display the current date and time on your device. A correct output will confirm that the latest date and time settings are in effect.

Uses

  • This variable is used to verify whether the current system date and time are correct.
  • Changing the current date and time according to «mm-dd-yy» and the «0:hh:mm:ss» 24-hour format.
List Environment Variables Date Time Windows11

6. %DriverData%

%DriverData% is a variable that refers to the DriverData folder on your Windows PC. It is located at «C:\Windows\System32\Drivers.» This is a central folder containing all of your driver information.

Uses

  • As the folder is accessible to «System Restore,» SFC, and other internal processes, its variable is very handy for locating possible errors.
  • While installing any new hardware, use the variable to check whether the DriverData folder has been affected.
List Environment Variables Driverdata Windows11

Also read: 15 Safe Websites for Downloading Windows Software

7. %HomeDrive%

The all-important C:\ drive is crucial to everything you do on your system. A command like %HomeDrive% (or %SystemDrive%) helps you open and view the location for further activity.

Uses

  • Access C:\ drive from anywhere on your PC.
  • Link with other environment variables, such as %CD% or %CommonProgramFiles%.
List Environment Variables Homedrive Windows11

8. %LogOnServer%

Every computer is connected to a a domain group or network of devices. %LogOnServer% displays the current Windows Logon server, which can be as simple as your computer name (below) or a corporate domain.

Uses

  • Quickly find out the Windows Logon server to which you’re authenticated.
  • Validate your user login to the correct Microsoft account.
List Environment Variables Logonserver Windows11

9. %Number_Of_Processors%

As the name suggests, %Number_Of_Processors% gives out the number of cores on your Windows CPU. The command returns a simple numeric value referring to the number of processor cores your device has.

Uses

  • Whether your PC has a dual (2), quad (4) or octa-core (8) processor configuration, using echo %Number_Of_Processors% is the fastest way to find out.
  • This is very useful when you want to learn whether you device will support certain games and applications that you want to run.
List Environment Variables Number Of Processors Windows11

Also read: How to Use Windows 11 without a Microsoft Account

10. %OneDrive%

The OneDrive folder contains all its essential applications, such as the Desktop, documents, and any files and folders synced with Microsoft’s Cloud servers. To open this folder, you can use its namesake environment variable, %OneDrive%.

Uses

  • Quickly access your Microsoft Cloud data from any location on your PC.
  • When using the OneDrive folder with Command Line, this variable will open the entire network path.
List Environment Variables Onedrive Folder Windows11

11. %OS%

Windows has been running its proprietary Windows NT operating system since 1993. Running an operating system-specific command like echo %OS% gives you a quick glimpse into your current operating system.

Uses

  • If you want to ensure that your current version of Windows is a valid copy (and not a pirated one), this variable gives you the confirmation.
List Environment Variables Os Winnt Windows11

12. %Path%

%Path% is one of the most common environment variables to be used on your Windows 10/11 device. When you run an echo %Path%, it gives you all the important Path files available on your PC.

Uses

  • View all your Windows Path files in one place. This includes the routine «C:\Windows\System32» and other file locations for PowerShell, WindowsApps and OpenSSH.
  • You can utilize these Path file locations with other commands.
List Environment Variables Path Windows11 1

13. %PathExt%

While installing native and third-party apps in Windows, you come across many files with extensions, such as .COM, .EXE, .BAT (Batch files), .VBS, .VBE, and so forth. %PathExt% makes you aware of all the file extension types you need to watch out for in the %Path% variable.

Uses

  • Know all the file extensions that can be executed from Command Prompt.
  • Start a program or script in Command line without specifying the suffix, such as .EXE.
List Environment Variables Pathext Command Windows11 1

Also read: How to Determine Whether a Website Is Legit and Safe to Use

14. %Processor_Architecture%

What kind of microprocessor does your Windows device contain? With a variable echo %Processor_Architecture%, you can easily tell whether you’re using Intel or AMD (or any other CPU), and whether it’s 64 or 32-bit.

Uses

  • Knowing the exact architecture your Windows device uses is helpful when you install compatible games and applications.
List Environment Variables Processor Architecture Windows11

15. %Processor_Identifier%

The echo %Processor_Identifier% variable goes deeper into CPU-specific information, including processor family and model series, whether it’s Genuine Intel or AMD, and what level of design change a processor was built into. (It’s called processor «stepping.»)

Uses

  • Advanced applications, such as creating Windows batch scripts or testing hardware failure.
  • Testing the hardware compatibility of external components, such as motherboard, RAM etc., with your Windows device.
List Environment Variables Processor Identifier Windows11

16. %Processor_Level%

In analyzing chip architecture, echo %Processor_Level% displays the processor level showing the model number of the CPU installed in your device. It is expressed numerically as 3,4, 5 (for x86) to 6 for (x64) computers.

Uses

  • Validating that you have the right processor capabilities on your processor as advertised by the chip-maker.
List Environment Variables Processor Level Windows11

17. %Processor_Revision%

While each processor is being designed, it goes through a series of design iterations. echo %Processor_Revision% tells you the revision number of the installed CPU. In other words, it lets you know how advanced a processor is.

Uses

  • When buying a new laptop, you can use this variable to make an informed decision in choosing a chipset.
List Environment Variables Processor Revision Windows11

Also read: What is Antimalware Service Executable? Why is CPU and Memory Usage High?

18. %ProgramData%

Much like Program Files, the Program Data folder is used by Windows to install standard applications but does not require higher level Administrator privileges. Using %ProgramData% gives you easy access to this folder.

Uses

  • Malware authors often try to attack the ProgramData folder, as tampering with its files can affect installed apps. Always keeping it hidden is important.
  • As an Admin user, you should stay on top of any changes in the folder. Use «System Restore» if you notice any errors.
List Environment Variables Programdata Windows11

19. %ProgramFiles%

The %ProgramFiles% and %ProgramFiles(86)% variables directly launch the respective Program Files and Program Files for 32-bit application folders. This allows you to view all your installed file components.

Uses

  • Add, edit and delete any program files directly in this section.
  • Are you unable to access the File Explorer for any reason? If so, %ProgramFiles% from the Run menu gives you quick access to this folder.
List Environment Variables Program Files Windows11

20. %Prompt%

The Prompt variable, %Prompt%, gives an indication of the current Command Prompt, validating whether your Command Prompt executable, cmd.exe is present in the correct folder path. It is written as echo %Prompt% and returns specific values as shown below.

Uses

  • The output Prompt text can be returned. It consists of various characters, where $P refers to a current drive and path, and $G means equal to or greater than. Thus, if you get an output such as $P$G, it means your cmd.exe is in the right folder.
List Environment Variables Prompt Command Windows11

21. %PSModulePath%

The Windows PowerShell script uses various modules located in different parts of a Windows PC. The %PSModulePath% variable used as echo %PSModulePath% displays all of the various locations for it, such as Program Files or System32.

Uses

  • PowerShell modules contain various components, such as Cmdlets, Providers, workflows, and aliases. These are frequently used in coding activity in sync with the main PowerShell window.
  • You can access them centrally with a %PSModulePath% variable without having to search for them individually.
List Environment Variables Psmodulepath Windows11

Also read: 14 Superior Alternatives for Preinstalled Windows Software & Utilities

22. %Public%

The variable %Public% when typed in the Run menu reveals the public users folder located at C:\Users\Public. It stores all the documents, downloads, music, and pictures attached to the publicly accessible folder.

Uses

  • Getting a birds-eye view of all user accounts registered in a Windows device.
  • Sharing data with others via your computer or network.
List Environment Variables Public Command Windows11

23. %Random%

The Command Prompt has its own variable, %Random%, which is used to generate a random number between 0 to 32767. To use it, you need to type echo %Random%, which will generate a number, such as 21907 shown here.

Uses

  • Random numbers are often used in Windows batch scripts for testing purposes.
  • If you are facing issues with numeric display on your device, test whether the random numbers are displaying correctly in Command line.
List Environment Variables Randomnumber Windows11

24. %SessionName%

If you are frequently using remote desktops, it may become hard to tell whether the current session being hosted is local to the device. This problem can be addressed using echo %SessionName%.

Uses

  • If the SessionName is shown as «Console,» you know that the session is local to your device.
  • Similarly, if you see an Output such as «RDP-Tcp#,» it will inform you whether you’re using a Remote Desktop session.
List Environment Variables Sessionname Windows11

25. %SystemRoot%

The System Root of your folder, C:\Windows, contains many utilities that are integral to your device performance. They can all be centrally accessed from the %SystemRoot% variable in theRun menu. Also check %WinDir%..

Uses

  • Accessing Control Panel applications as they’re directly linked to System Root folder.
  • The System Root contains utilities such as «Fonts.» You can directly open these folder paths from Run menu and operate on them using Command Prompt.
List Environment Variables Systemroot Windows11

26. %Temp%

One of the best known applications of environment variables, the temporary files folders can be accessed using %Temp% or %Tmp% in Run menu.

Uses

  • Instead of remembering the entire path «C:\Users\AppData\Local\Temp,» you can simply open the temporary files folder with a simple and easy to remember command.
  • Delete as many temporary files as you want to free up space on your device and improve PC performance.
List Environment Variables Temp Folder Windows11

Also read: How to Fix the Network Cable Unplugged Error in Windows

27. %UserDomain%

Every desktop device is marked by a user domain. To know where your current user is being hosted, you can check the domain with an environment variable called %UserDomain%. It has to run with an echo command as echo %UserDomain%.

Uses

  • Mapping the current PC user’s desktop session with its username.
  • Setting up Group user policies for several users.
List Environment Variables Userdomain Windows11

28. %UserProfile%

If there are multiple usernames registered on a Windows device, it becomes difficult to tell which user is connected to a current desktop profile. Using a Run menu variable, such as %UserProfile%, will get you a complete view.

Uses

  • Accessing and managing multiple user profiles registered on a Windows PC.
  • Deleting and editing the desktop, documents, and downloads for multiple user profiles (something only Admin users can do).
List Environment Variables Userprofiles Windows11

29. %WinDir%

The %WinDir% is similar to %SystemRoot%, in that both point to the C:\Windows location on your PC. However, unlike the latter, WinDir can be used to launch standard Windows system calls to open a folder or get a specific output. It is also more commonly used in the latest Windows devices.

Uses

  • Centrally access error reports pertaining to system faults, as all of them link to the %WinDir% variable and its location C:\Windows.
  • The WinDir folder is closely linked to the administrator account and 64-bit applications.
List Environment Variables Windir Windows11

30. %ZES_ENABLE_SYSMAN%

Sysman means System Resource Management library. This covers many things in Windows 11/10, such as power management of various system components. To enable this setting, you need to input echo %ZES_ENABLE_SYSMAN%.

Uses

  • If the Output value returns itself as 1, then it means that the default SysMan settings for the CPU have been initialized.
  • On some Windows devices, you can use echo %ZES_ENABLE_SYSMAN_LOW_POWER% to ensure low power settings. Thus, both Sysman commands can be used to turn the current low power settings On or Off.
List Environment Variables Zes Enable Sysman Windows11

Also read: How to Downgrade from Windows 11 to Windows 10

Frequently Asked Questions

How can I resolve Windows environment variables that are not recognized?

If one or more of your Windows environment variables are not being recognized, it is possible that their settings are missing on your device. Go to “View Advanced System Settings” from the search menu and open Environment Variables, then add those missing environment variables one by one. Close the window and try resolving the issue.

How can I export and import environment variables in Windows?

To export or import environment variables in Windows, you need to open the Registry Editor from the Run menu (regedit.exe). You will find environment variables here under «HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment» and «HKEY_CURRENT_USER\Environment.» You can export and import the new environment variables in this section’s right panel.

How do I refresh environment variables in Windows?

In the Command Prompt window, using the «cls» command will clear the screen and refresh all the environment variables for you. But to do that properly, you need to first set the variables at their respective locations. See this detailed guide on how to set variables correctly.

Image credit: Pixabay All screenshots by Sayak Boral

Sayak Boral

Sayak Boral is a technology writer with over eleven years of experience working in different industries including semiconductors, IoT, enterprise IT, telecommunications OSS/BSS, and network security. He has been writing for MakeTechEasier on a wide range of technical topics including Windows, Android, Internet, Hardware Guides, Browsers, Software Tools, and Product Reviews.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

  • Windows update что это за программа можно ли удалить
  • Windows usb serial converter driver windows 7
  • Windows update отсутствует в реестре
  • Windows update что это за папка
  • Windows update отказано в доступе