Admin - Force Batch File To Run As

Alan smiled. "This one could."

He sighed. He could use a scheduled task with highest privileges. Or he could cheat. force batch file to run as admin

He opened Notepad and loaded the batch file. At the very top, above the del commands and the rmdir sweeps, he typed: Alan smiled

Alan had three choices: rewrite the script in PowerShell (too late), stay up until 3 AM clicking "Yes" on a UAC prompt (no), or force the batch file to demand admin rights itself. force batch file to run as admin

@echo off net session >nul 2>&1 if %errorlevel% neq 0 ( echo Requesting administrator privileges... powershell start -verb runas '%0' exit /b ) He saved it. Double-clicked.

The script ran. Logs vaporized. Drives cleared.