Self Escalating Batch

use this version of Sudo for Windows… it goes to some length to keep the activity inside the current dos console.

 1 2 3 4 5 6 7 8 910
@echo off
setlocal

::self escalate
net session >nul 2>&1
::we need the timeout here versus in the main body logic...
::because sudo remaps stdin which then fails  timeout's "press any key to continue" 
if %errorlevel% NEQ 0 (sudo %0 & timeout /t 5 & exit /b)

::...rest of your logic...

comments powered by Disqus