In my day-to-day job of managing a large number of servers, quite often
I run into a situation where I must schedule a job to run on a remote
server. By using the AT command, I can simply setup my scheduled job
and be on my way.
The syntax for the AT command is:
AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"
Specifies a remote computer. Commands are scheduled on the local
computer if this parameter is omitted.
Is an identification number assigned to a scheduled command.
Cancels a scheduled command. If id is omitted, all the scheduled
commands on the computer are canceled.
Used with cancel all jobs command when no further confirmation is
Specifies the time when command is to run.
Allows the job to interact with the desktop of the user who is logged on
at the time the job runs.
Runs the command on each specified day(s) of the week or month. If date
is omitted, the current day of the month is assumed.
Runs the specified command on the next occurrence of the day (for
example, next Thursday). If date is omitted, the current day of the
month is assumed.
Is the Windows NT command, or batch program to be run.
Most of the options that are available to the AT command are
self-explanatory, however, there are a couple of options that need some
First, to see the jobs that have been successfully scheduled with the AT
command, all you need to do is type 'AT' at the command prompt.
Now let's look at some of the options that need further explanation.
The 'time' option is based upon the 24-hour clock, not the 12-hour
clock. This means that if you want something to run at 8:00PM, then you
need to specify time as 20:00.
For the 'date' portion of the '/every' and '/next' options, you need to
use the following abbreviations for the days of the week:
Last, the 'command' option, which is the most important, has a few
caveats. First, if there are spaces in the command path, you need to
make sure that the command is surrounded by double quotes. If the
command is a local path on the remote machine, you need to include the
absolute path name, including the drive letter. Additionally, if the
command is being run from another machine, then you must use the UNC
path name in the form \\server\sharename. Last, if the command is not
an executable (i.e. a batch file or VBScript), then you must precede the
command with "cmd /c". For example, let's assume that I want the target
server called 'serverName' to run a batch file on the C-drive called
test.bat every Monday at 8PM. The AT command I would use is:
AT \\servername 20:00 /EVERY:M "cmd /c c:\test.bat"
As you can see, I had to precede my non-executable (.exe) batch file
with 'cmd /c' in addition to including the full absolute path name to
the batch file.
One last thing to note is that the Task Scheduler can see the jobs that
you scheduled with the AT command, however, if you modify any of your AT
jobs using the Task Scheduler GUI, you will no longer be able to see
your AT jobs when you type 'AT' at the command prompt.
Using the AT command is easy once you know the above potential gotchas.