Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

cmd refresh path

# Add these lines to a batch file, which
# you can then call to refresh the path
# variable of your current session:

@echo off
echo | set /p dummy="Reading environment variables from registry. Please wait... "
goto main
:SetFromReg
    "%WinDir%System32Reg" QUERY "%~1" /v "%~2" > "%TEMP%\_envset.tmp" 2>NUL
    for /f "usebackq skip=2 tokens=2,*" %%A IN ("%TEMP%\_envset.tmp") do (
        echo/set %~3=%%B
    )
    goto :EOF
:GetRegEnv
    "%WinDir%System32Reg" QUERY "%~1" > "%TEMP%\_envget.tmp"
    for /f "usebackq skip=2" %%A IN ("%TEMP%\_envget.tmp") do (
        if /I not "%%~A"=="Path" (
            call :SetFromReg "%~1" "%%~A" "%%~A"
        )
    )
    goto :EOF
:main
    echo/@echo off >"%TEMP%\_env.cmd"
    call :GetRegEnv "HKLMSystemCurrentControlSetControlSession ManagerEnvironment" >> "%TEMP%\_env.cmd"
    call :GetRegEnv "HKCUEnvironment">>"%TEMP%\_env.cmd" >> "%TEMP%\_env.cmd"
    call :SetFromReg "HKLMSystemCurrentControlSetControlSession ManagerEnvironment" Path Path_HKLM >> "%TEMP%\_env.cmd"
    call :SetFromReg "HKCUEnvironment" Path Path_HKCU >> "%TEMP%\_env.cmd"
    echo/set Path=%%Path_HKLM%%;%%Path_HKCU%% >> "%TEMP%\_env.cmd"
    del /f /q "%TEMP%\_envset.tmp" 2>nul
    del /f /q "%TEMP%\_envget.tmp" 2>nul
    call "%TEMP%\_env.cmd"
    echo | set /p dummy="Done"
    echo .
Comment

PREVIOUS NEXT
Code Example
Shell :: github add all files/directories and subdirectories 
Shell :: gunicorn port 8080 
Shell :: displaying the last line of output bash 
Shell :: apt get update upgrade linux 
Shell :: where is my ubuntu folder located 
Shell :: how to merge branches github 
Shell :: push git repo to github 
Shell :: git clone single branch 
Shell :: docker start container 
Shell :: linux format disk fat32 
Shell :: check all ruby version ubuntu 
Shell :: There is 1 zombie process 
Shell :: vim :qa! 
Shell :: ssh server windows 11 
Shell :: how to see deleted commit in git 
Shell :: run disk usage analyzer as root 
Shell :: ubuntu software not showing apps 20.04 
Shell :: how to see ip in linux 
Shell :: git update .gitignore 
Shell :: get only file names from CMD 
Shell :: install composer in ubuntu 
Shell :: how to kill a service based on port number on mac 
Shell :: command to Change User Primary Group 
Shell :: top linux 
Shell :: adobe reader for ubuntu 20.04 
Shell :: how to get all avd names in cmd 
Shell :: android studio tortoisegit 
Shell :: deleting index.lock 
Shell :: git tag from commit 
Shell :: Git: Unexpected identifier git commit error 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =