Created
December 26, 2015 21:55
-
-
Save elitak/994cde4163ec5813f6fa to your computer and use it in GitHub Desktop.
Busybox bootstrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set PATH=%~dp0;.;%PATH% | |
for %%I in (busybox.exe) do set BUSYBOX=%%~$PATH:I | |
REM this is still wrong if scriptname has a space in it | |
REM (bug? just don't put a space in this filename) | |
set ORIGPATH=%~f0 | |
"%BUSYBOX%" sed "1,/^#!\/bin\/bash/d" "%ORIGPATH%" > "%TEMP%\%~n0.sh" | |
REM NB ECHO echoes literal quotes; ()& must be escaped by ^ | |
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%TEMP%\OEgetPrivileges.vbs" | |
REM ^& chr(34) HACK is to insert escaped quotes | |
ECHO UAC.ShellExecute "%BUSYBOX%", "bash %TEMP%\%~n0.sh " ^& chr(34) ^& "%ORIGPATH%" ^& chr(34) ^& " %*", "", "runas", 1 >> "%TEMP%\OEgetPrivileges.vbs" | |
"%TEMP%\OEgetPrivileges.vbs" | |
exit /B | |
#!/bin/bash | |
origpath=$1 ; shift | |
# Everything above this point can be used as a generic template for | |
# bootstrapping an admin-privileged bash script, to follow. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment