Force Batch File To Run As Admin (2026)

The problem was simple, infuriatingly so: the cleanup script—a humble cleanup_logs.bat —needed admin rights to delete the old system logs. But the scheduled task kept running it under the SYSTEM account with limited token privileges, and the junior admin who set it up was long gone.

He opened the script again. This time, he added a scheduled task inside the batch file that ran itself as admin without prompting—the nuclear option. force batch file to run as admin

But then—Server 47 hung.

Alan stared at the blinking cursor on his screen. It was 11:47 PM. The server migration was supposed to be done by 9. The problem was simple, infuriatingly so: the cleanup

schtasks /create /tn "AdminElevate_%random%" /tr "%~dp0cleanup_logs.bat" /sc once /st 00:05 /rl highest /f schtasks /run /tn "AdminElevate_%random%" It worked. The task spawned, elevated silently, ran the script, and self-deleted. This time, he added a scheduled task inside