Last active
January 18, 2024 15:02
-
-
Save wangmuy/b82f7d976914db5d1497aaadef6b16ed to your computer and use it in GitHub Desktop.
refresh path in windows shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo. | |
echo Refreshing PATH from registry | |
setlocal EnableDelayedExpansion | |
:: Get System PATH | |
for /f "tokens=3*" %%A in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path') do set syspath=%%A%%B | |
:: Get User Path | |
for /f "tokens=3*" %%A in ('reg query "HKCU\Environment" /v Path') do set userpath=%%A%%B | |
:: Set Refreshed Path | |
set PATH=%userpath%;%syspath% | |
echo Refreshed PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
set OLD_PATH=%PATH%
...
set PATH=%OLD_PATH%;%userpath%;%syspath%
Вот так работает