function RefreshEnv { $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") # Add other variables similarly } Send a system-wide notification that environment variables changed. Apps that listen (like Explorer) will reload.
echo %MY_VAR% $env:MY_VAR
for /f "usebackq tokens=1,2,*" %A in (`reg query "HKCU\Environment"`) do set %A=%C (For system variables, use HKLM path with admin rights.) # Reload user + system env variables into current session $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") Or use a reusable function: windows reload env variables