Thursday, March 22, 2012

Start cmd.exe as system in 1 minute

Not sure exactly why I wrote this one but it's come in handy a few times. For those times when Admin rights just aren't enough...

Starts cmd.exe running as system from the AT task scheduler one minute from the time the script is run.

-=The Script=-

@echo off
set tm=%time:~3,2%
set hr=%time:~0,2%
if "%hr:~0,1%"==" " set hr=0%time:~1,1%
set tens=%time:~3,1%
set ones=%time:~4,1%
echo %tm%
echo %tens%
echo %ones%
if %ones% == 0 set bt=1
if %ones% == 1 set bt=2
if %ones% == 2 set bt=3
if %ones% == 3 set bt=4
if %ones% == 4 set bt=5
if %ones% == 5 set bt=6
if %ones% == 6 set bt=7
if %ones% == 7 set bt=8
if %ones% == 8 set bt=9
if %ones% == 9 set goto jmpten
at %hr%:%tens%%bt% /interactive cmd.exe

if %tens% == 0 set btt=1
if %tens% == 1 set btt=2
if %tens% == 2 set btt=3
if %tens% == 3 set btt=4
if %tens% == 4 set btt=5
if %tens% == 5 set btt=6
if %tens% == 6 set btt=7
if %tens% == 7 set btt=8
if %tens% == 8 set btt=9
if %tens% == 9 set goto badend
at %hr%:%btt%%bt% /interactive cmd.exe

echo I'm lazy and didn't want to code this extra bit for the event of an hour change
echo Just wait a minute and run it again.
pause > nul

No comments:

Post a Comment

All comments moderated.
Comments like "sweet dude" or "this is awesome" or "thanks" will be denied,
if you've got something genuinely interesting to say, say it. Other than that just sit back and bask in the glory.