]> git.donarmstrong.com Git - qmk_firmware.git/blob - util/1-setup-path-win.bat
Merge remote-tracking branch 'remotes/jackhumbert/master'
[qmk_firmware.git] / util / 1-setup-path-win.bat
1 @SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
2 @ECHO OFF
3 SET CMDLINERUNSTR=%SystemRoot%\system32\cmd.exe
4
5 CD UTIL
6 DEL add-paths.log > NUL 2>&1
7 DEL add-paths-detail.log > NUL 2>&1
8 DEL UPDATE > NUL 2>&1
9
10 ELEVATE -wait %cd%\add-paths.bat > NUL 2>&1
11
12 IF ERRORLEVEL 1 (
13         ECHO You denied admin access. Rerun the script, and be sure to press the yes button this time.
14 ) ELSE (
15         TYPE add-paths.log 2> NUL
16 )
17 ECHO.
18
19 :: Branch to UpdateEnv if we need to update
20 IF EXIST UPDATE (
21         DEL UPDATE
22         GOTO UpdateEnv
23 )
24
25 GOTO ExitBatch
26
27 :: -----------------------------------------------------------------------------
28
29 :UpdateEnv
30 ECHO Making updated PATH go live . . .
31 REG delete HKCU\Environment /F /V TEMPVAR > NUL 2>&1
32 setx TEMPVAR 1 > NUL
33 REG delete HKCU\Environment /F /V TEMPVAR > NUL 2>&1
34 IF NOT !cmdcmdline! == !CMDLINERUNSTR! (CALL :KillExplorer)
35 GOTO ExitBatch
36
37 :: -----------------------------------------------------------------------------
38
39 :ExitBatch
40 ENDLOCAL
41 PAUSE
42 EXIT /b
43
44 :: -----------------------------------------------------------------------------
45
46 :KillExplorer
47 ECHO Your desktop will be restarted. 
48 ECHO All file explorer windows except for the one you launched this script from WILL BE CLOSED.
49 ECHO Press enter when ready, or close this window if you would rather do a full restart of your computer at a later time.
50 PAUSE
51 ping -n 5 127.0.0.1 > NUL 2>&1
52 ECHO Killing process Explorer.exe. . . 
53 ECHO.  
54 taskkill /f /im explorer.exe > NUL
55 ECHO.   
56 ECHO Your desktop is now loading. . . 
57 ECHO.   
58 ping -n 5 127.0.0.1 > NUL 2>&1
59 START explorer.exe
60 START explorer.exe %CD%\..
61 EXIT /b