Environment variables are kept in HKEY_LOCAL_MACHINE\SYSTEM\ControlSet\Control\Session Manager\Environment.
Many of the useful env vars, such as Path, are stored as REG_SZ. There are several ways to access the registry including REGEDIT:
REGEDIT /E <filename> "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment"
The output starts with magic numbers. So to search it with the find command it needs to be typed and redirected: type <filename> | findstr -c:\"Path\"
So, if you just want to refresh the path variable in your current command session with what's in system properties the following batch script works fine:
RefreshPath.cmd:
@echo off REM This solution requests elevation in order to read from the registry. if exist %temp%\env.reg del %temp%\env.reg /q /f REGEDIT /E %temp%\env.reg "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment" if not exist %temp%\env.reg ( echo "Unable to write registry to temp location" exit 1 ) SETLOCAL EnableDelayedExpansion for /f "tokens=1,2* delims==" %%i in ('type %temp%\env.reg ^| findstr -c:\"Path\"=') do ( set upath=%%~j echo !upath:\\=\! >%temp%\newpath ) ENDLOCAL for /f "tokens=*" %%i in (%temp%\newpath) do set path=%%i