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

how to refresh environment variables in windows

Overview –
Environment Variables in Windows

It seems that you’re learning to program and trying to refresh environment variables in Windows 11 without rebooting your computer and restarting your project and disrupting the workflow.

The Windows OS provides a way for system administrators to change the values of environment variables in the registry. A special section of the registry called “Environment” contains all user-defined environment variables. You can modify these values through the use of the “Regedit” application.

An environment variable is a named object that contains data used by one or more applications. The environment variables are stored in the registry, where they can be viewed and edited using standard tools.

By the end of this article, you’ll be able to refresh environment variables in Windows without rebooting your computer:

Using Chocolatey Package Manager (Recommended)

Using Command Prompt

What are Environment
Variables in Windows

Variables are used to store many sorts of data. System settings, inventory statuses, and other data can be stored in these variables. Environment Variables are a type of variable that contains environmental information about a computer. The environment variables in Windows can be used to make changes to the system without having to edit the registry.

The variables in the environment are used to define variables for a variety of purposes. Windows itself does not require them. You put up these variables, and they determine how Windows runs it. You can use them, for example, to identify your user or its location.

Environment Variables in Windows help you to assign values that will be used during the process of execution of any command on your computer. This will allow these commands to execute on a given set of values, altering their appearance.

1. Refresh
Environment Variables via Chocolatey Package Manager
(Recommended)

Step 1: Open the Command Prompt from the Start menu, copy and paste the following command to install chocolatey package manager on your PC:

@”%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe” -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command “[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString(‘https://community.chocolatey.org/install.ps1’))” && SET “PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin”

command-to-install-chocolatey-to-refresh-environment-variables.webp

Command to install Chocolatey using CMD

Step 2: After installing the Chocolatey Package Manager, type the command “refreshenv” (without quotation marks) to refresh system variables.

command-to-refresh-environment-variables-using-chocolatey-tool.webp

Refresh environment variables using chocolatey

NOTE: After the installation of the chocolatey package manager, every time you type and execute the “refreshenv” command, the environment variables will be refreshed immediately, without the need to restart the computer.

2. Refresh
Environment Variables via Command Prompt (CMD)

Step 1: In the Start menu, search for Command Prompt and run it as an administrator.

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

Command Prompt (CMD) Icon

Step 2: Type the command: “set PATH = c” (without quotation marks), press the enter key, and restart the Command Prompt.

set-path-c-command.webp

“set PATH = c” command

Step 3: Type the command: “echo %PATH%” (without quotation marks) and press the enter key to reset system variables using CMD.

echo-path-command-to-refresh-environment-variables.webp

“echo %Path%” command

NOTE: After installing the PostgreSQL (PgAdmin 4), I tried this way to update environment variables, and it worked nicely.

FAQs Related to
Environment Variables

What
is the difference between System variables and Environment
variables?

System environment variables are globally accessed by all users. The user Environment variables are specific only to the currently logged-in user and remain the default for the other users.

Where are the
system variables stored in the registry?

The actual location of system variables in the registry is: HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Control > Session Manager > Environment.

Are environment
variables stored in memory?

Environment variables and command line parameters are kept together at the top of the process memory structure, above the layer.

Next
Steps

When you change the value of an environment variable in windows, the changes are not applied to your current windows session. You have to either log out and log in again or restart your device. But, in this article, we’ve covered how to reset environment variables in Windows 11 without rebooting the computer.

Variables can be accessed through DOS commands by typing “set”. They can also be accessed through other programs such as PowerShell and Command Prompt using the Control Panel applet or any other number of available applications for manipulating environment variables.

It’s important to know that the changes you make in the environment variables will be modified for other users of the system as well. They should not, however, be confused with Environment Variables in Windows.

Further, customize your computer’s configuration by referring to the related articles below.

Users can edit the path environment variables on Windows 10. It’s really easy to do though you need admin rights to make the changes. The path environment variables aren’t all populated by users. There are a few default paths that are part of it. Users can always add or remove them. If you’ve accidentally deleted a single path environment variable, or all of them, you can add them back. If you don’t remember every single path that was added, you can try a few things to restore path environment variables on Windows 10.

Limitations

There are limitations to the methods we’re going to list for recovering the path environment variables. The first is that you should not have restarted your system after removing/deleting them. If you have Command Prompt or PowerShell open, your chances of recovering the path environment variables is much better.

Windows Registry

Tap the Win+R keyboard shortcut to open the run box. In the run box, enter ‘regedit’. Tap Enter. Once the registry editor is open, navigate to the following location;

HKEY_CURRENT_USER\Environment

The values under this key will list the path environment variables. Double-click to open them and copy the path from them all to Notepad. Go ahead and add them back.

It is possible that the Environment key is empty. This is most likely to happen if you restarted your system. In such an event, search the registry for a key named ‘Environment’ and check the values under whatever comes up in the results.

PowerShell

If you already have PowerShell open from before the variables were deleted, switch to it and run the following command. It will be able to read the old path environment variables. You can try running it in a new PowerShell window but it may not work.

Get-ItemProperty -Path "HKCU:\Environment"

Command Prompt

Like the PowerShell method, this too only works if you have a Command Prompt window open from before you deleted or modified the variables. Run the following command and it will return the path environment variables.

echo %PATH%

NTUSER.DAT backup

If you have a back up of your user profile, look for a file called NTUSER.DAT in it. This file’s contents will have your old path environment variables in it. Of course, this method relies on the back up existing in the first place.

The above methods work but they require certain conditions to be met. It goes without saying that it isn’t easy to recover path environment variables once they’re lost and in many cases, you might be better off restoring your system.

default avatar image

Fatima Wahab

Fatima has been writing for AddictiveTips for six years. She began as a junior writer and has been working as the Editor in Chief since 2014.

Fatima gets an adrenaline rush from figuring out how technology works, and how to manipulate it. A well-designed app, something that solves a common everyday problem and looks

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

In this article, we are going to see how to set, edit and delete environment variables in Windows 11 operating system along with step by step guide with the help of appropriate screenshots. Different-2 programs require different environment variable settings to be executed.
The environment is mainly used to store the information about the system environment running in the current machine.

Basically, The meaning of setting the environment variable is creating a shortcut to start a program instead of remembering the location of the program. By creating the environment you can start the program just by typing a single keyword.
That’s why it is one of the most important for windows users to know how to set environment variables in windows 11.

Headings of Contents

  • 1 What is Environment Variable in Windows?
  • 2 Why You Need to Environment Variable
  • 3 How to Set Environment Variables in Windows 11?
  • 4 How to Change the Environment Variable in Windows 11
  • 5 How to Delete Environment Variable in windows 11
  • 6 How to Set Environment Variable using Command Prompt
  • 7 Changing environment variable using command prompt
  • 8 Access Environment Variable using Command Prompt
  • 9 Setting Environment Variable using Windows Powershell
  • 10 How to Access Environment Variable using Powershell
  • 11 Changing Environment Variable using Windows PowerShell
  • 12 Deleting Environment Variable using Windows Powershell
  • 13 Conclusion

What is Environment Variable in Windows?

The environment variable is the process of setting the dynamic variable value in the machine. In other words, the Environment variable is the way to store the global variable value that is used by all the processes and users that are running under the machine. Environment variables represent the new software installation directory location, Windows Operating system file location, etc. The value of the environment variable is used by the programs to determine where the files are stored actually.

These are some common environment variables available in the windows operating system.

  • Path:- Path is one of the most popular environment variables in the windows operating system that is used to store the list of directories to search for executable programs and also it is one of the most frequently used environment variables.
  • Username:- This is for the username of the system.
  • OS:- The operating system name.

There are other environment variables available except all of the above.

Why You Need to Environment Variable

Windows Environment variables are used to store the data that are used by windows and other programs. For example, windir environment variable stores the location of the Windows installation directory. Programs can query the value of this variable to find where the files of the Windows operating system are located.

There are two types of environment variables available in windows machines first are system variables and the second is user variables that are logged in. Logged-in users can only change their own environment variable if they don’t have administration permission even another user can not change the environment variable.

Let’s take another example about environment variable so that you can get more clarity, Suppose you are going to install Python on your machine and then during the installation of the Python it will ask you, to add a python executable file to your environment variable if you do not check that setting and continue the installation. After successfully the installation of Python you are ready to execute any Python script but you have to remember one thing each time you have to specify the location of the Python executable to execute the Python script but if you check that setting during the installation then you don’t need to specify the location of the Python executable each time.

But after the installation of Python or any software you can manually set the environment variable.

Let’s see how can you set a new environment variable in your windows 11 machine.

Note:- All the variable names which I will set, edit and delete throughout this article will just be for testing. You can set your own required environment variable.

How to Set Environment Variables in Windows 11?

With the help of the following points you can set your environment variable in your windows machine.Here I will go with windows 11 machine.

  • To set the environment variable in Windows you have to right-click on This PC icon and again click on Properties.
  • Now you have to click on “Advanced system settings“.

  • Click on “Environment Variables“.
  • After clicking on Environment variables, you can see all your system environment variables ( User and System ) very clearly.
    1. User Variables:- User variable will contain environment variables about the current logged-in user, If you want to change the environment variable of the logged-in user then you have to change it inside this variables section.
    2. System Variables:- System variable contains variables and values system-wide.This variable will be available for all the users across the machine which means it is a system-wide change.

You can choose according to your need. Here I am going with User variables.

  • After deciding your appropriate environment variables section, click on New.
  • Now, It will ask you to provide the variable name and value of the variable. Here I am setting the Java executable environment variable and after that click OK until all the open environment variables windows are gone.

So finally we have seen the whole process to set new environment variables in the windows 11 machine.

How to Change the Environment Variable in Windows 11

Here I’m gonna show you, how you can change or edit the environment variable.

  • To change the environment variable, press “Windows + R” and type “sysdm.cpl” and hit enter.
  • Go to Advanced > Environment variables section
  • Select the environment variable which you want to change and click edit
  • Provide variable name and variable value as your wish and then click Ok

How to Delete Environment Variable in windows 11

Sometimes you require to delete existing environment variables. With the help of these steps, you can delete any existing environment variables.

  • To delete the environment variable, press “Windows + R” and type “sysdm.cpl” and hit enter.
  • Go to Advanced > Environment variables section.
  • Select the environment variable which you want to delete and click delete.
  • After clicking on delete, your environment variables will be deleted successfully.

How to Set Environment Variable using Command Prompt

Windows command prompt also provides us with some useful commands to work with windows environment variables. here I am going to show how to set environment variables using a command prompt.

  • First, you need to open your command prompt, To open the command prompt press “Windows + R” and type “cmd“, and hit enter.
  • Windows provide a useful command “set” to set the environment variable. The syntax for setting the new environment variable is that set variable_name=variable_value. Here I am going to set an environment variable website=Proogramming Funda so my whole command would be set website=Proogramming Funda.

To verify whether the environment variable was created or not, you can execute the set command. This command shows all the environment variables with values.

Changing environment variable using command prompt

To change the existing environment variable, you have re-assign the value of the existing environment variable by using the following command.

set variable_name=variable_value

Note:- Make sure you are not going to change the variable name.

Access Environment Variable using Command Prompt

To access the existing environment variable in the windows machine, Open the command prompt and issue the set variable_name statement.
Here variable_name represents the name of the variable which you want to access.

As you can see from below the screenshot, I am accessing the website environment variable.

Setting Environment Variable using Windows Powershell

Here I’m gonna show you can set, edit and delete the environment variable using Windows PowerShell.

  • To open Powershell, Press “Windows + R” type “PowerShell” and hit enter.
  • The following is the syntax of the setting new environment variable in windows with help of the windows PowerShell.
$Env:<variable-name> = value

In the above syntax, variable-name represents the name of the variable which you want to keep, and the value represents the value of a variable.

So here I am going to set a variable name website along with the value “Programming Funda“.

How to Access Environment Variable using Powershell

  • To access the existing environment variable using Windows Powershell, Search “Powershell” in the search bar and open windows power shell.
  • The syntax for accessing the environment variable is “$Env:variable_name“. Here I am going to see the value of an environment variable named website.

Changing Environment Variable using Windows PowerShell

If you want to change the value of the existing environment variable using windows PowerShell, Then you have to re-assign the value of the environment variable. As you can see below the image.

Deleting Environment Variable using Windows Powershell

To delete the environment variable in a windows machine using PowerShell you have to assign the blank string to that variable. As you can see below screenshot.

Conclusion

So in this article, we have seen all about how to set, edit, and delete environment variables in windows 11. Here I have more than one method to set, delete and edit windows environment variables as per your choice.

Environment variables is basically a process of storing variables and their values globally in the system so that programs, processes, and users determine where the configuration files, installation directory, drivers, and executable
are stored.

I hope this article is very useful for you. If you like this article please share and keep visiting for further interesting tutorials.

Ref:- Click Here

Thanks for your valuable time …

Environment variables is not a new term in context to Windows 10. People have known them for years, as they are available in Windows series since older days of Windows XP. But still the fact is that many newbies to Windows aren’t aware of them. In this article, we’ll let you know about these variables and show the way to edit or modify them.

Basically, environment variables are strings that contain information such as drive, path, or file name. They control the behavior of various programs. For example, %windir% is an environment variable which when run in Command Prompt, opens the Windows folder under system root drive such as C:\Windows. There are two kind of environment variables a Windows operating system have. The first category is of user environment variables, which the user(s) and/or administrator(s), both can modify anytime. Second class is of system environment variables, which only system admin(s) can modify.

Keep in mind that the user environment variables are different for each user of a particular computer. The variables include any that are set by the user, as well as any variables defined by programs, such as the path to the location of the program files. While for system environment variables, administrators can change or add environment variables that apply to the system, and thus to all system users. During installation, Windows Setup configures the default system variables, such as the path to the Windows files.

Page Contents

How To Change User And System Environment Variables In Windows 10

1. Open administrative or elevated Windows PowerShell. For this search in Windows by term windows powershell, pick Windows PowerShell from search results, right click on it and select Run as administrator.

Recommended : Use Windows PowerShell to find Windows Experience Index on Windows 10

2. Next, in the Windows PowerShell window, type following cmdlet and press Enter key:

Get-ChildItem Env:

How To Change System And User Environment Variables In Windows 10

This cmdlet output will show you the list all environment variables available on your system. You can also edit or modify the variables in Windows PowerShell itself, but this would be bit technical. So for the sake of readers, I’ll show you much familiar way to edit these variables.

Registry Disclaimer: The further steps will involve registry manipulation. Making mistakes while manipulating registry could affect your system adversely. So be careful while editing registry entries and create a System Restore point first.

3. Press + R and put regedit in Run dialog box to open Registry Editor (if you’re not familiar with Registry Editor, then click here). Click OK.

Windows 10 Registry Editor

4. In the left pane of Registry Editor, navigate to following registry key:

HKEY_CURRENT_USER\Environment

How To Change System And User Environment Variables In Windows 10

5. At this registry location as shown above, you can see there are two user environment variables by default. To add a new environment variable, right click on blank space in the right pane, select New -> Expandable String Value. Change the string name so created from New Value #1 to whatever you want to say the variable. Now, for existing variables, double click on the variable string to add or modify its Value data:

Put you desired Value data in Edit String window and click OK. In this way, you can add or modify user environment variables.

6. In order to modify system environment variables, navigate to following registry key and perform the registry manipulation as described in previous step:

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

How To Change System And User Environment Variables In Windows 10

We’ve highlighted some important variables in the screenshot above. So in this way, you can add or modify system environment variables. You may need to restart your system, to make your changes effective.

List of environment variables in Windows 10

For your convenience, here is the complete list of environment variables in Windows 10.

ENVIRONMENT VARIABLES
VALUES (items in italic – variables)
%ALLUSERSPROFILE% C:\ProgramData
%APPDATA% C:\Users\(user-name)\AppData\Roaming
%CD% Current directory full path
%CMDCMDLINE% Returns exact command line used to start current cmd.exe session.
%CMDEXTVERSION% Number of current command processor extensions.
%CommonProgramFiles% C:\Program Files\Common Files
%CommonProgramFiles(x86)% C:\Program Files (x86)\Common Files
%CommonProgramW6432% C:\Program Files\Common Files
%COMPUTERNAME% Technoyl-PC
%COMSPEC% C:\Windows\System32\cmd.exe
%DATE% Current date in format determined by Date command
%ERRORLEVEL% Number defining exit status of previous command or program
%HOMEDRIVE% C:
%HOMEPATH% C:\Users\(user-name)
%LOCALAPPDATA% C:\Users\(user-name)\AppData\Local
%LOGONSERVER% \\MicrosoftAccount
%NUMBER_OF_PROCESSORS% 1
%OS% Windows_NT
%PATH% C:\WINDOWS

C:\WINDOWS\system32

C:\WINDOWS\System32\Wbem

C:\WINDOWS\System32\WindowsPowerShell\v1.0

%PATHEXT% COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
%PROCESSOR_ARCHITECTURE% x86
%PROCESSOR_IDENTIFIER% x86 Family 6 Model 69 Stepping 1, GenuineIntel
%PROCESSOR_LEVEL% 6
%PROCESSOR_REVISION% 4501
%ProgramData% C:\ProgramData
%ProgramFiles% C:\Program Files
%ProgramFiles(x86)% C:\Program Files (x86)
%ProgramW6432% C:\Program Files
%PROMPT% Code for current command prompt format. Code is usually $P$G
%PSModulePath% C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
%PUBLIC% C:\Users\Public
%RANDOM% To get random number between 0 and 32767
%SessionName% When logging on directly to machine, returns “Console”.

When client connects via terminal server session, is combination of

connection name, followed by pound symbol {#} and session number.

%SystemDrive% C:
%SystemRoot% C:\Windows
%TEMP% C:\Users\(user-name)\AppData\Local\Temp
%TIME% Current time in format determined by Time command
%TMP% C:\Users\(user-name)\AppData\Local\Temp
%USERDOMAIN% Technoyl-PC
%USERDOMAIN_ROAMINGPROFILE% Technoyl-PC
%USERNAME% (user-name)
%USERPROFILE% C:\Users\(user-name)
%WINDIR% C:\Windows

Hope you find the article useful! Also learn how to scan your Windows 10 using Windows PowerShell.

RELATED ARTICLES

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

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Ошибка при обновлении windows 10 0x80244010
  • Восстановление windows defender в windows 10
  • Windows media creation tool windows 10 pro 64 bit
  • Как установить ubuntu server рядом с windows 10
  • Как перейти в спящий режим windows 10 сочетание клавиш