Skip to content

Instantly share code, notes, and snippets.

@wangmuy
Last active January 18, 2024 15:02
Show Gist options
  • Save wangmuy/b82f7d976914db5d1497aaadef6b16ed to your computer and use it in GitHub Desktop.
Save wangmuy/b82f7d976914db5d1497aaadef6b16ed to your computer and use it in GitHub Desktop.
refresh path in windows shell
@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
@senja006
Copy link

set OLD_PATH=%PATH%
...
set PATH=%OLD_PATH%;%userpath%;%syspath%
Вот так работает

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment