Using the Windows
Job Scheduler at.exe
utility
The AT
command can be used to schedule commands and
programs on Windows NT, Windows 2000, Windows XP
and Windows 2003.
For the command to work, the scheduler
service must be running.
On Windows 2000, this can be done using
the services dialog (Start
à
Programs
à
Administrative Tools
à
Services) or from the command line using the net
command:
net stop "Task Scheduler"
net start "Task Scheduler"
The at /? command produces the following:
AT [\\computername] [ [id]
[/DELETE] | /DELETE [/YES]]
AT [\\computername] time
[/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]]
"command"
A couple of simple examples of its use include:
C:> at 21:00 /every:m,t,th,f
"c:\jobs\MyJob.bat"
Added a new job with job
ID = 1
C:> at 6:00 /next:20 "c:\jobs\MyJob.bat"
Added a new job with job
ID = 2
The first example schedules a job which runs the
c:\jobs\MyJob.bat script at 9:00
p.m. on Mondays, Tuesdays, Thursdays and
Fridays.
The second example schedules a job that
runs the script at 6:00 a.m. on the next 20th of
the month.
The current list of jobs can be displayed
by issuing the AT command with no parameters:
Status ID
Day
Time
Command Line
--------------------------------------------------------------------
1
Each M T Th F
21:00
PM
c:\jobs\MyJob.bat
2
Next 20
06:00 AM
c:\jobs\MyJob.bat
C:\>
Jobs can be deleted using the /delete option:
C:\>at 1 /delete
C:\>at 2 /delete
C:\>at
There are no entries in
the list.
The AT
scheduler has been in Windows scheduling for
many years, but recent Windows versions have
introduced simpler and more flexible
alternatives which will be covered in the
following section.
Using the Windows Scheduled Tasks Wizard
In Windows, there is a GUI tool called the
Scheduled Tasks Wizard,
which is far more convenient than the AT
command.
It is available from the
Control Panel or from the task bar (Start
à
Programs
à
Accessories
à
System Tools
à
Scheduled Tasks).
The resulting dialog lists the current
scheduled tasks and an
Add
Scheduled Task
icon, as seen in Figure 11.3.
Figure 11.3 –
Scheduled Tasks Dialog with no Scheduled
Jobs
To schedule a new task, simply double click on
the Add Scheduled Task
icon, which starts the
Scheduled Tasks Wizard
as shown in Figure 11.4.
Figure 11.4 –
Scheduled Tasks Wizard
Clicking the Next button produces a list of
programs that can be scheduled as shown in
Figure 11.5.
If the program or script that is desired
is not available in the list, the Browse button
allows the user to select alternatives from the
file system.
Figure 11.5 –
Scheduled Tasks Wizard:
Program List
Once the relevant command or script is selected,
clicking the Next button displays a screen that
allows a name and basic schedule to be
associated with the task as shown in Figure
11.6.
Figure 11.6 –
Scheduled Tasks Wizard:
Name and Basic Schedule
The contents of the next screen vary depending
on the type of basic schedule selected.
Figure 11.7 shows the additional schedule
information that can be defined for a daily
task.
Figure 11.7 –
Scheduled Tasks Wizard: Additional
Scheduling Options
The next screen permits authorization
credentials for the task to be assigned,
allowing the task to run as any valid operating
system user.
It is important that tasks run with the
correct credentials as running tasks under
privileged accounts can introduce potential
security holes.
Figure 11.8 –
Scheduled Tasks Wizard:
Authorization Details
Finally, a summary page is displayed which gives
the option of displaying the advanced properties
dialog once the job definition is complete.
If this option is left unchecked,
clicking the Finish button displays the original
scheduled tasks list.
Figure 11.9 –
Scheduled Tasks Wizard:
Summary
The newly scheduled task is now displayed in the
scheduled tasks dialog:
Figure 11.10 –
Scheduled Tasks Dialog with Newly Scheduled
Job Listed
Right clicking on the job and selecting the
Properties option from the pop-up menu, as in
Figure 11.11, displays the advanced properties
dialog.
This dialog allows the task definition to
be modified after it is created.
Figure 11.11 –
Scheduled Job Properties Dialog
The following section will present the
SCHTASKS
command which provides a more feature-rich
command line alternative to the AT
command.