Skip navigation

Q. How can I generate a time that is 2 minutes in the future and is suitable for using with the AT command?

I have scripted AT2.bat to generate a time that is 2 minutes in the future, and is suitable for using with the AT command.

NOTE: If you install Soon.exe, the near-future command scheduler, you don't need this tip.

The syntax for using AT2.bat is:

\[call\] AT2 TPlusTwo

Where TPlusTwo is a call directed environment variable that will contain a time, that is two minutes in the future, and suitable for using with the AT command.

AT2.bat contains:

@echo off
if \{%1\}==\{\} @echo Syntax: AT2 Time&goto :EOF
setlocal
set vb="%TEMP%\AT2_%RANDOM%.vbs"
@echo.Wscript.Echo DateAdd("n", "2", (now))>%vb%
for /f "Tokens=1*" %%a in ('cscript //nologo %vb%') do (
 set tm=%%b
)
set tm=%tm: =%
del /q %vb%
endlocal&set %1=%tm%


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish