aboutsummaryrefslogtreecommitdiff
path: root/1-setup-path-win.bat
diff options
context:
space:
mode:
authorNoah Andrews <NoahAndrews@users.noreply.github.com>2016-06-02 13:00:44 -0400
committerJack Humbert <jack.humb@gmail.com>2016-06-02 13:00:44 -0400
commitc7005cdfcf4e4a3fc4abd536afd9fb9a378994fb (patch)
treeae1846953613304d918c0010aefdfc9c9b6bc1a3 /1-setup-path-win.bat
parent4635b4453335b61df11008fa907eef221db5912b (diff)
downloadqmk_firmware-c7005cdfcf4e4a3fc4abd536afd9fb9a378994fb.tar.gz
qmk_firmware-c7005cdfcf4e4a3fc4abd536afd9fb9a378994fb.zip
Stops explorer.exe from being started with admin privilieges (#373)
Diffstat (limited to '1-setup-path-win.bat')
-rw-r--r--1-setup-path-win.bat72
1 files changed, 28 insertions, 44 deletions
diff --git a/1-setup-path-win.bat b/1-setup-path-win.bat
index f612d0f4a..92e91be3e 100644
--- a/1-setup-path-win.bat
+++ b/1-setup-path-win.bat
@@ -2,25 +2,25 @@
2@ECHO OFF 2@ECHO OFF
3SET CMDLINERUNSTR=%SystemRoot%\system32\cmd.exe 3SET CMDLINERUNSTR=%SystemRoot%\system32\cmd.exe
4 4
5SET NEWPATH1="C:\MinGW\msys\1.0\bin" 5CD UTIL
6SET NEWPATH2="C:\MinGW\bin" 6DEL add-paths.log > NUL 2>&1
7DEL add-paths-detail.log > NUL 2>&1
8DEL UPDATE > NUL 2>&1
9
10ELEVATE -wait %cd%\add-paths.bat > NUL 2>&1
7 11
8:: Make sure we're running with administrator privileges
9NET SESSION >nul 2>&1
10IF ERRORLEVEL 1 ( 12IF ERRORLEVEL 1 (
11 ECHO FAILED. Run this script with administrator privileges. 13 ECHO You denied admin access. Rerun the script, and be sure to press the yes button this time.
12 GOTO ExitBatch 14) ELSE (
15 TYPE add-paths.log 2> NUL
13) 16)
14 17ECHO.
15:: Make sure the second path exists. The first path won't be created until the second script is run
16IF NOT EXIST !NEWPATH2! (ECHO Path not found: %NEWPATH2% && GOTO ExitBatch)
17
18:: Add paths
19CALL :AddPath %NEWPATH1%
20CALL :AddPath %NEWPATH2%
21 18
22:: Branch to UpdateEnv if we need to update 19:: Branch to UpdateEnv if we need to update
23IF DEFINED UPDATE (GOTO UpdateEnv) 20IF EXIST UPDATE (
21 DEL UPDATE
22 GOTO UpdateEnv
23)
24 24
25GOTO ExitBatch 25GOTO ExitBatch
26 26
@@ -28,9 +28,9 @@ GOTO ExitBatch
28 28
29:UpdateEnv 29:UpdateEnv
30ECHO Making updated PATH go live . . . 30ECHO Making updated PATH go live . . .
31REG delete HKCU\Environment /F /V TEMPVAR > nul 2>&1 31REG delete HKCU\Environment /F /V TEMPVAR > NUL 2>&1
32setx TEMPVAR 1 > nul 2>&1 32setx TEMPVAR 1 > NUL
33REG delete HKCU\Environment /F /V TEMPVAR > nul 2>&1 33REG delete HKCU\Environment /F /V TEMPVAR > NUL 2>&1
34IF NOT !cmdcmdline! == !CMDLINERUNSTR! (CALL :KillExplorer) 34IF NOT !cmdcmdline! == !CMDLINERUNSTR! (CALL :KillExplorer)
35GOTO ExitBatch 35GOTO ExitBatch
36 36
@@ -43,35 +43,19 @@ EXIT /b
43 43
44:: ----------------------------------------------------------------------------- 44:: -----------------------------------------------------------------------------
45 45
46:AddPath <pathToAdd>
47ECHO %PATH% | FINDSTR /C:"%~1" > nul
48IF ERRORLEVEL 1 (
49 REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /f /v PATH /t REG_SZ /d "%PATH%;%~1" > nul 2>&1
50 IF ERRORLEVEL 0 (
51 ECHO Adding %1 . . . Success!
52 SET "PATH=%PATH%;%~1"
53 SET UPDATE=1
54 ) ELSE (
55 ECHO Adding %1 . . . FAILED. Run this script with administrator privileges.
56 )
57) ELSE (
58 ECHO Skipping %1 - Already in PATH
59 )
60EXIT /b
61
62:: -----------------------------------------------------------------------------
63
64:KillExplorer 46:KillExplorer
65 47ECHO Your desktop will be restarted.
66ECHO Your desktop is being restarted, please wait. . . 48ECHO All file explorer windows except for the one you launched this script from WILL BE CLOSED.
67ping -n 5 127.0.0.1 > NUL 2>&1 49ECHO Press enter when ready, or close this window if you would rather do a full restart of your computer at a later time.
68ECHO Killing process Explorer.exe. . . 50PAUSE
69taskkill /f /im explorer.exe 51ping -n 5 127.0.0.1 > NUL 2>&1
52ECHO Killing process Explorer.exe. . .
53ECHO.
54taskkill /f /im explorer.exe > NUL
70ECHO. 55ECHO.
71ECHO Your desktop is now loading. . . 56ECHO Your desktop is now loading. . .
72ping -n 5 127.0.0.1 > NUL 2>&1
73ECHO. 57ECHO.
74ping -n 5 127.0.0.1 > NUL 2>&1 58ping -n 5 127.0.0.1 > NUL 2>&1
75START explorer.exe 59START explorer.exe
76START explorer.exe %CD% 60START explorer.exe %CD%\..
77EXIT /b \ No newline at end of file 61EXIT /b \ No newline at end of file