aboutsummaryrefslogtreecommitdiff
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
parent4635b4453335b61df11008fa907eef221db5912b (diff)
downloadqmk_firmware-c7005cdfcf4e4a3fc4abd536afd9fb9a378994fb.tar.gz
qmk_firmware-c7005cdfcf4e4a3fc4abd536afd9fb9a378994fb.zip
Stops explorer.exe from being started with admin privilieges (#373)
-rw-r--r--.gitignore3
-rw-r--r--1-setup-path-win.bat72
-rw-r--r--BUILD_GUIDE.md4
-rw-r--r--util/ELEVATE_LICENSE.md25
-rw-r--r--util/add-paths.bat30
5 files changed, 88 insertions, 46 deletions
diff --git a/.gitignore b/.gitignore
index a082ea22e..83f3f2da9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@ keyboard/planck/dfu-programmer.exe
4*.eep 4*.eep
5*.elf 5*.elf
6*.hex 6*.hex
7*.log
7*.lss 8*.lss
8*.lst 9*.lst
9*.map 10*.map
@@ -14,6 +15,8 @@ tags
14build/ 15build/
15*.bak 16*.bak
16.vagrant/ 17.vagrant/
18.idea/
19CMakeLists.txt
17.DS_STORE 20.DS_STORE
18 21
19# Eclipse/PyCharm/Other IDE Settings 22# Eclipse/PyCharm/Other IDE Settings
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
diff --git a/BUILD_GUIDE.md b/BUILD_GUIDE.md
index fd8b6202f..089d63834 100644
--- a/BUILD_GUIDE.md
+++ b/BUILD_GUIDE.md
@@ -2,12 +2,12 @@
2 2
3## Build Environment Setup 3## Build Environment Setup
4 4
5### Windows 5### Windows (Vista and later)
61. If you have ever installed WinAVR, uninstall it. 61. If you have ever installed WinAVR, uninstall it.
72. Install [MHV AVR Tools](https://infernoembedded.com/sites/default/files/project/MHV_AVR_Tools_20131101.exe). Disable smatch, but **be sure to leave the option to add the tools to the PATH checked**. 72. Install [MHV AVR Tools](https://infernoembedded.com/sites/default/files/project/MHV_AVR_Tools_20131101.exe). Disable smatch, but **be sure to leave the option to add the tools to the PATH checked**.
83. Install [MinGW](https://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download). During installation, uncheck the option to install a graphical user interface. **DO NOT change the default installation folder.** The scripts depend on the default location. 83. Install [MinGW](https://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download). During installation, uncheck the option to install a graphical user interface. **DO NOT change the default installation folder.** The scripts depend on the default location.
94. Clone this repository. [This link will download it as a zip file, which you'll need to extract.](https://github.com/jackhumbert/qmk_firmware/archive/master.zip) Open the extracted folder in Windows Explorer. 94. Clone this repository. [This link will download it as a zip file, which you'll need to extract.](https://github.com/jackhumbert/qmk_firmware/archive/master.zip) Open the extracted folder in Windows Explorer.
105. Right-click on the 1-setup-path-win batch script, select "Run as administrator", and accept the User Account Control prompt. Press the spacebar to dismiss the success message in the command prompt that pops up. 105. Double-click on the 1-setup-path-win batch script to run it. You'll need to accept a User Account Control prompt. Press the spacebar to dismiss the success message in the command prompt that pops up.
116. Right-click on the 2-setup-environment-win batch script, select "Run as administrator", and accept the User Account Control prompt. This part may take a couple of minutes, and you'll need to approve a driver installation, but once it finishes, your environment is complete! 116. Right-click on the 2-setup-environment-win batch script, select "Run as administrator", and accept the User Account Control prompt. This part may take a couple of minutes, and you'll need to approve a driver installation, but once it finishes, your environment is complete!
127. Future build commands should be run from the standard Windows command prompt, which you can find by searching for "command prompt" from the start menu or start screen. Ignore the "MHV AVR Shell". 127. Future build commands should be run from the standard Windows command prompt, which you can find by searching for "command prompt" from the start menu or start screen. Ignore the "MHV AVR Shell".
13 13
diff --git a/util/ELEVATE_LICENSE.md b/util/ELEVATE_LICENSE.md
new file mode 100644
index 000000000..1cf4fda91
--- /dev/null
+++ b/util/ELEVATE_LICENSE.md
@@ -0,0 +1,25 @@
1Elevate was downloaded from [here](https://jpassing.com/2007/12/08/launch-elevated-processes-from-the-command-line/).
2
3### LICENSE
4
5The MIT License (MIT)
6
7Copyright (c) <year> <copyright holders>
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE. \ No newline at end of file
diff --git a/util/add-paths.bat b/util/add-paths.bat
new file mode 100644
index 000000000..ab3d91da1
--- /dev/null
+++ b/util/add-paths.bat
@@ -0,0 +1,30 @@
1@SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
2@ECHO off
3
4SET NEWPATH1="C:\MinGW\msys\1.0\bin"
5SET NEWPATH2="C:\MinGW\bin"
6
7CD %~dp0
8
9ECHO. > add-paths.log
10
11CALL :AddPath %NEWPATH1%
12CALL :AddPath %NEWPATH2%
13
14EXIT /b
15
16:AddPath <pathToAdd>
17ECHO %PATH% | FINDSTR /C:"%~1" > nul
18IF ERRORLEVEL 1 (
19 REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /f /v PATH /t REG_SZ /d "%PATH%;%~1" >> add-paths-detail.log
20 IF ERRORLEVEL 0 (
21 ECHO Adding %1 . . . Success! >> add-paths.log
22 SET "PATH=%PATH%;%~1"
23 COPY NUL UPDATE
24 ) ELSE (
25 ECHO Adding %1 . . . FAILED. Run this script with administrator privileges. >> add-paths.log
26 )
27) ELSE (
28 ECHO Skipping %1 - Already in PATH >> add-paths.log
29 )
30EXIT /b \ No newline at end of file