This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
fuss:dos [2018/01/06 18:34] – office | fuss:dos [2019/04/12 16:31] – [Blank the Screen from Command Line] office | ||
---|---|---|---|
Line 32: | Line 32: | ||
Note that '' | Note that '' | ||
+ | |||
+ | ====== Reload / Refresh Environment Variables ====== | ||
+ | |||
+ | The following script from chocolatey reloads the environment variables on Windows. | ||
+ | <code dos> | ||
+ | @echo off | ||
+ | :: | ||
+ | :: RefreshEnv.cmd | ||
+ | :: | ||
+ | :: Batch file to read environment variables from registry and | ||
+ | :: set session variables to these values. | ||
+ | :: | ||
+ | :: With this batch file, there should be no need to reload command | ||
+ | :: environment every time you want environment changes to propagate | ||
+ | |||
+ | ::echo " | ||
+ | echo | set /p dummy=" | ||
+ | |||
+ | goto main | ||
+ | |||
+ | :: Set one environment variable from registry key | ||
+ | :SetFromReg | ||
+ | " | ||
+ | for /f " | ||
+ | echo/set " | ||
+ | ) | ||
+ | goto :EOF | ||
+ | |||
+ | :: Get a list of environment variables from registry | ||
+ | :GetRegEnv | ||
+ | " | ||
+ | for /f " | ||
+ | if /I not " | ||
+ | call :SetFromReg " | ||
+ | ) | ||
+ | ) | ||
+ | goto :EOF | ||
+ | |||
+ | :main | ||
+ | echo/@echo off >" | ||
+ | |||
+ | :: Slowly generating final file | ||
+ | call :GetRegEnv " | ||
+ | call :GetRegEnv " | ||
+ | |||
+ | :: Special handling for PATH - mix both User and System | ||
+ | call :SetFromReg " | ||
+ | call :SetFromReg " | ||
+ | |||
+ | :: Caution: do not insert space-chars before >> redirection sign | ||
+ | echo/set " | ||
+ | |||
+ | :: Cleanup | ||
+ | del /f /q " | ||
+ | del /f /q " | ||
+ | |||
+ | :: capture user / architecture | ||
+ | SET " | ||
+ | SET " | ||
+ | |||
+ | :: Set these variables | ||
+ | call " | ||
+ | |||
+ | :: Cleanup | ||
+ | del /f /q " | ||
+ | |||
+ | :: reset user / architecture | ||
+ | SET " | ||
+ | SET " | ||
+ | |||
+ | echo | set /p dummy=" | ||
+ | echo . | ||
+ | </ | ||