O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  



soon.bat for Windows
Previous versions of the Windows Resource Kit shipped with a utility called "soon.exe". This useful little tool used the Windows scheduler service to make a deferred command happen "real soon now" -- great when you need to launch something (like cmd.exe or regedit) in the local system security context. Unfortunately, soon.exe does not ship with the current resource kit. The attached batch file provides basically the same functionality.

Contributed by:
Unknown User anonymous2
[04/16/04 | Discuss (2) | Link to this hack]

@if (%_echo%)==() echo off
setlocal

if (%1)==() goto Usage
set _command=%*

for /F "tokens=1,2,3 delims=:." %%i in ("%time%") do call :DoIt %%i %%j %%k
goto :EOF

:DoIt
rem %1 = hour
rem %2 = minute
rem %3 = second
set _hour=%1
if (%_hour:~0,1%)==(0) set _hour=%_hour:~1%
set _minute=%2
if (%_minute:~0,1%)==(0) set _minute=%_minute:~1%
set /a _minute+=1
if %3 GEQ 55 set /a _minute+=1
if %_minute% LSS 60 goto :DontFixMinute
set /a _minute-=60
set /a _hour+=1
:DontFixMinute
if %_hour% LSS 24 goto :DontFixHour
set /a _hour-=24
:DontFixHour
rem schedule it
at %_hour%:%_minute% /interactive %_command%
rem print the current schedule list
at
rem print the current time
time < nul | findstr -i current
goto :EOF

:Usage
echo use: soon command [parameters]
goto :EOF


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.