1 @SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
3 SET CMDLINERUNSTR=%SystemRoot%\system32\cmd.exe
5 SET NEWPATH1="C:\MinGW\msys\1.0\bin"
6 SET NEWPATH2="C:\MinGW\bin"
8 :: Make sure we're running with administrator privileges
11 ECHO FAILED. Run this script with administrator privileges.
15 :: Make sure the second path exists. The first path won't be created until the second script is run
16 IF NOT EXIST !NEWPATH2! (ECHO Path not found: %NEWPATH2% && GOTO ExitBatch)
19 CALL :AddPath %NEWPATH1%
20 CALL :AddPath %NEWPATH2%
22 :: Branch to UpdateEnv if we need to update
23 IF DEFINED UPDATE (GOTO UpdateEnv)
27 :: -----------------------------------------------------------------------------
30 ECHO Making updated PATH go live . . .
31 REG delete HKCU\Environment /F /V TEMPVAR > nul 2>&1
32 setx TEMPVAR 1 > nul 2>&1
33 REG delete HKCU\Environment /F /V TEMPVAR > nul 2>&1
34 IF NOT !cmdcmdline! == !CMDLINERUNSTR! (CALL :KillExplorer)
37 :: -----------------------------------------------------------------------------
44 :: -----------------------------------------------------------------------------
47 ECHO %PATH% | FINDSTR /C:"%~1" > nul
49 REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /f /v PATH /t REG_SZ /d "%PATH%;%~1" > nul 2>&1
51 ECHO Adding %1 . . . Success!
55 ECHO Adding %1 . . . FAILED. Run this script with administrator privileges.
58 ECHO Skipping %1 - Already in PATH
62 :: -----------------------------------------------------------------------------
66 ECHO Your desktop is being restarted, please wait. . .
67 ping -n 5 127.0.0.1 > NUL 2>&1
68 ECHO Killing process Explorer.exe. . .
69 taskkill /f /im explorer.exe
71 ECHO Your desktop is now loading. . .
72 ping -n 5 127.0.0.1 > NUL 2>&1
74 ping -n 5 127.0.0.1 > NUL 2>&1
76 START explorer.exe %CD%