Обновить переменные среды без перезагрузки windows 10

Update

I haven’t used Windows for over a decade, but this page gets a lot of hits, so I
leave it here assuming and hopeful it is helpful.

I find it quite annoying that whenever I read instructions that include adding
an environment path variable you are asked to reboot your machine for changes to
take effect. I know there has GOT to be a way to do it. Well, I know a way, but
it’s someway kludgy.

Here is how I do it (I’m really hoping someone will comment and tell me a better
way)

  1. Open your system properties window. Screenshots below are for Vista:

    computer properties

  2. Open you Environment Variables Window.

    system properties

  3. Double Click on you Path (if you want to just change you path for your login,
    use the top one, if you want to change it for all logins, use the bottom one)

  4. Append the path you would like to add, separated with a semi-colon. Below, I
    am adding C:\CmdShortcuts

Now, reboot your computer! Argh! J/K

Here is the kludgy hack that I use so I don’t have to reboot. (But it will not
work in all cases, which is why I don’t like it, so please, if you know of a
batch script or something I can run that will apply the changes made to the
environment variables without rebooting, please post a comment.)

Open a comment window and type SET PATH=%PATH%;C:\CmdShortcuts

You can type PATH again to see your path variables. Your new path should be
added. The problem with this is that this new path variable is only good inside
this command window. If you are doing command line stuff this works, but if you
close your cmd window the change is lost.



Posted on

|



In

win10

description: Add a windows environment varibale without rebooting the computer

process to refresh environment variables without reboot windows

  • open cmd commend prompt window
  • input set PATH=C -> this will refresh the environment variables
  • close and restart cmd window
  • input echo %PATH% to test
  • Post author: killfun
  • Post link:
    http://search4fan.github.io/post/win10_new_system_variable_without_restart.html
  • Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.

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.


Изменение переменных окружения без перезагрузки

От:

DemAS

http://demas.me
Дата:  04.12.07 06:30
Оценка:

6 (1)
+1

Возможно ли в Win менять значения переменных окружения буз перезагрузки?

Да и вообще, существует ли удобный инструментарий для работы с ними. Стандартный похож на издевательство ибо:
— если переменная длинная и является перечислением (типа PATH), то фиг в ней что найдешь в этом маленьком окошке, который предлагается для ее редактирования
— чтобы ввести новую переменную нужно нажать Добавить, нужно что-то написать в очень маленьком окошке и нажать ОК

IMHO обычный текстовый файл был бы и то удобнее, и не было бы очередной проблемы

— резервного копирования эих переменных

Кстати, почему после изменения переменной окрыжения нужно обязательно перезагружаться иначе она не вступит в силу? Что за такие важные структуры инициализуруются в windows internals, что я не могу прописать путь где ОС будет искать файлы без ее перезагрузки? Бред? Или я что-то не понимаю?

Кроме того надоели такие вещи:

После установки компилятора необходимо проверить, что в переменной окружения PATH прописан путь:
<путь к компилятору>bin\i386-win32\;
Причём, он должен там быть раньше, чем пути к остальным FPC, если их в системе несколько. Кроме того, если в системе установлен, например, MinGW, то, если, в PATH путь к нему прописан раньше, чем к FPC, то будет использован не ld из FPC, а ld из MinGW и ничего собрать не удастся.

В общем, может кто-то нашел что-то удобное, чтобы сосуществовать рядом с этим безобразием?

p.s. Linux не предлагать

… << RSDN@Home 1.2.0 alpha rev. 786>>


Re: Изменение переменных окружения без перезагрузки

От:

Sergeant_BY

Беларусь

 
Дата:  04.12.07 07:07
Оценка:

4 (1)

Здравствуйте, DemAS, Вы писали:

DAS>Возможно ли в Win менять значения переменных окружения буз перезагрузки?

Без перезагрузки процесса которому нужно перечитать обновленный environment — нет.
Без перезагрузки всей системы — пожалуй да.

DAS> Да и вообще, существует ли удобный инструментарий для работы с ними. Стандартный похож на издевательство ибо:

DAS> — если переменная длинная и является перечислением (типа PATH), то фиг в ней что найдешь в этом маленьком окошке, который предлагается для ее редактирования — чтобы ввести новую переменную нужно нажать Добавить, нужно что-то написать в очень маленьком окошке и нажать ОК
setx path «%PATH%;C:\New Folder»
setx — из ресурскита к XP, например.

DAS> IMHO обычный текстовый файл был бы и то удобнее, и не было бы очередной проблемы

Удобнее чем и в каком виде?
Кстати «эти маленькие окошки» — просто frontend к редактированию значений в HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment Т.е. если удобнее для этого пользоваться текстовыми файлами (для импорта в regedit, например) — пожалуйста.
Но запуск/перезапуск процесса которому нужно перечитать изменения понадобится по любому.

DAS> — резервного копирования эих переменных

set > backup_env.txt ?

DAS> Кстати, почему после изменения переменной окрыжения нужно обязательно перезагружаться иначе она не вступит в силу? Что за такие важные структуры инициализуруются в windows internals, что я не могу прописать путь где ОС будет искать файлы без ее перезагрузки? Бред? Или я что-то не понимаю?

Оккрываю System properties->Advanced->Environment, добавляю какую-нибудь лабуду в конце %PATH%, нажимаю ОК.
Запускаю cmd, пишу set и вижу в %PATH% ту самую лабуду.
Что я делаю не так?

DAS> Кроме того надоели такие вещи:

DAS>

DAS> После установки компилятора необходимо проверить, что в переменной окружения PATH прописан путь:
DAS><путь к компилятору>bin\i386-win32\;
DAS>Причём, он должен там быть раньше, чем пути к остальным FPC, если их в системе несколько. Кроме того, если в системе установлен, например, MinGW, то, если, в PATH путь к нему прописан раньше, чем к FPC, то будет использован не ld из FPC, а ld из MinGW и ничего собрать не удастся.

DAS> В общем, может кто-то нашел что-то удобное, чтобы сосуществовать рядом с этим безобразием?
DAS> p.s. Linux не предлагать
А в Linux’е разве по другому?
Предложите другой разумный способ указания путей для поиска исполняемых файлов для запуска с системой приоритетов…


Re: Изменение переменных окружения без перезагрузки

От:

DOOM

Россия

 
Дата:  04.12.07 07:11
Оценка:

2 (1)

Здравствуйте, DemAS, Вы писали:

DAS>Возможно ли в Win менять значения переменных окружения буз перезагрузки?

Конечно.

DAS> Да и вообще, существует ли удобный инструментарий для работы с ними. Стандартный похож на издевательство ибо:

DAS> — если переменная длинная и является перечислением (типа PATH), то фиг в ней что найдешь в этом маленьком окошке, который предлагается для ее редактирования
DAS> — чтобы ввести новую переменную нужно нажать Добавить, нужно что-то написать в очень маленьком окошке и нажать ОК

DAS> IMHO обычный текстовый файл был бы и то удобнее, и не было бы очередной проблемы


DAS> — резервного копирования эих переменных

Ну тут да… Косяк. Можно напрямую через реестр, если этот способ можно назвать удобным…
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment — это системные переменные
HKEY_CURRENT_USER\Environment — пользовательские

Кроме того, в Support Tools’ах есть утилита setx, которая, в отличие от set позволяет делать постоянные изменения в переменных окружения.

DAS> Кстати, почему после изменения переменной окрыжения нужно обязательно перезагружаться иначе она не вступит в силу? Что за такие важные структуры инициализуруются в windows internals, что я не могу прописать путь где ОС будет искать файлы без ее перезагрузки? Бред? Или я что-то не понимаю?

Видать что-то не понимаешь. В винде, как и во многих других ОС, окружение привязано к процессу — поэтому, чтобы отразить изменения в окружении надо перезапустить процесс. Т.е. поменял PATH, перезапусти cmd.exe и он уже будет с новыми путями.

DAS> Кроме того надоели такие вещи:



DAS>

DAS> После установки компилятора необходимо проверить, что в переменной окружения PATH прописан путь:
DAS><путь к компилятору>bin\i386-win32\;
DAS>Причём, он должен там быть раньше, чем пути к остальным FPC, если их в системе несколько. Кроме того, если в системе установлен, например, MinGW, то, если, в PATH путь к нему прописан раньше, чем к FPC, то будет использован не ld из FPC, а ld из MinGW и ничего собрать не удастся.


Не вижу проблемы. Сделай себе 2 скрипта — один при запуске cmd добавляет в PATH пути к MinGW, другой к чему-нибудь еще. Запускай нужный и не засоряй общесистемные переменные…

DAS> В общем, может кто-то нашел что-то удобное, чтобы сосуществовать рядом с этим безобразием?


Ну что знал, то предложил…

DAS> p.s. Linux не предлагать

А там по сути также. Переменные окружения вещь очень старая и ведет себя так, как это было придумано десятилетия назад.


Re[2]: Изменение переменных окружения без перезагрузки

От:

DemAS

http://demas.me
Дата:  04.12.07 07:18
Оценка:

Здравствуйте, Sergeant_BY, Вы писали:

S_B>setx path «%PATH%;C:\New Folder»

S_B>setx — из ресурскита к XP, например.

Спасибо, гораздо удобнее.

DAS>> — резервного копирования эих переменных

S_B>set > backup_env.txt ?

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

S_B>Оккрываю System properties->Advanced->Environment, добавляю какую-нибудь лабуду в конце %PATH%, нажимаю ОК.

S_B>Запускаю cmd, пишу set и вижу в %PATH% ту самую лабуду.
S_B>Что я делаю не так?

Я тоже вижу. Но если я пытаюсь запустить exe-к из каталога, находящегося в добавленной директории — система говорит, что не знает такого.
Хотя возможно это я ступил — наверное надо было перезапустить cmd.

DAS>> p.s. Linux не предлагать

S_B>А в Linux’е разве по другому?

Не знаю. Но на всякий случай предупредил. Спасибо

… << RSDN@Home 1.2.0 alpha rev. 786>>


Re: А вот в лиинуксе!….

От:

Sheridan

Россия

 
Дата:  04.12.07 07:47
Оценка:


…belive in the matrix…

Posted via RSDN NNTP Server 2.1 beta

Matrix has you…

  • Переместить
  • Удалить
  • Выделить ветку

Пока на собственное сообщение не было ответов, его можно удалить.

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

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

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Что будет если установить windows 10 без ключа активации
  • Как подключиться через прокси сервер windows 10
  • Несколько рабочих экранов windows 10
  • Какие две команды можно использовать на узле windows чтобы отобразить таблицу маршрутизации
  • Windows уже использует такое имя введите другое имя пользователя