|
|
AT.exe
Schedule a batch file to run on a computer at a specific date
and time.
syntax Create an AT job: AT [\\computername] hh:mm [/INTERACTIVE] [ /EVERY:day(s) | /NEXT:day(s) ] "command" Delete an AT job: AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]] key
\\computername : Execute the AT command on a remote computer. id : An id number AT assigns to each scheduled job. /delete : Cancel a scheduled job. If id is omitted, all jobs are deleted. /yes : Use with /delete to supress the confirmation message. hh:mm : The time to run the command. /interactive : Allow the job to interact with the desktop of the current user when the job runs. /every:day(s) : Run the command every day(s) of the week or month. (default: dd=today) /next:day(s) : Run the command on the next occurrence of the day. (default: dd=today) "command" : The batch program or command to run. If the path to this includes spaces, put double quotation marks around the path. "C:\Program Files\My Batch.cmd"
Day(s) are in this format: (English Locale EN)
Monday = m
Tuesday = t
Wednesday = w
Thursday = th
Friday = f
Saturday = s
Sunday = su
or a specific day of the month:
e.g. 5th of every month = 5
Examples:
Running a command every day
AT_DAILY.cmd
::::::::::::
AT 23:30 /EVERY:m,t,w,th,f,s,su c:\backups\every_day.cmd
::::::::::::
Running a command every Friday
AT_WEEKLY.cmd
::::::::::::
AT 23:30 /EVERY:f c:\backups\weekly.cmd
::::::::::::
Resetting the above AT commands
RESET_AT_JOBS.cmd
::::::::::::
AT /delete /yes
CALL AT_DAILY
CALL AT_WEEKLY
::::::::::::
Running a command this evening (once only)
AT_TODAY.cmd
::::::::::::
AT 23:30 /NEXT: c:\backups\today.cmd
::::::::::::
Rights needed to issue an AT command
By default only a Local Administrator can issue an AT command, a Domain
Admin can direct the command at any machine.
To configure an AT job as part of a users login script - the user must be a
member of the local Administrators group.
Schedule vs Task Sheduler
The "Schedule" service must be running to use the AT command. If
you have Internet Explorer 5.0 or greater this is renamed as the "Task
Scheduler"
service. Task Scheduler initially had a bad reputation due to a security vulnerability
it introduced - however this was fixed with
IE 5.01
The "Schedule" service (ATSVC) rather than the "Task Scheduler"
service must be running to use SOON with a delay of less than 60 seconds. -
see Q237840
You can use the Scheduled Tasks folder to view or modify the settings of a
task that was created by using the AT command. When you schedule a task using
the at command, the task is listed in the Scheduled Tasks folder, with a name
such as:At3478. However, if you modify an AT task through the
Scheduled Tasks folder, it is upgraded to a normal scheduled task. The task
is no longer visible to the at command, and the at account setting no longer
applies to it. You must explicitly enter a user account and password for the
task.
Commands to Process
At does not automatically load Cmd.exe, the command interpreter. If you are not running an executable (.exe) file, you must explicitly load Cmd.exe at the beginning of the command e.g. cmd /c dir
Don't try to pass more than one command into AT, put everything you want to achieve in one batch file and then call the batch file from AT.
User Rights needed for the AT command to perform it's task
The User Account under which the Schedule service runs may require specific
file access permissions, user permissions and drive mappings.
The User Account is selected under MyComputer,
ScheduledTasks, Advanced (Menu), AT Service Account. You also need to stop
and restart the service before the change in UserAccount will take effect.
Here's how to check if a user account has sufficent rights for a particular
task:
AT hh:mm /interactive %comspec% /k
Setting hh:mm for one minute from now will open a cmd window at the specified
time. In this window you can check the following settings:
Next, go ahead and run your batch file in this console window,
note the errors, and fix them. Once the errors have been fixed, you can remove
the /interactive switch and schedule the batch file with some confidence that
it will work as intended.
Bugs
If you change the system time after scheduling
a command with AT, synchronize the scheduler with the revised system
time by typing AT without any command-line options.
By default, AT jobs will stop
running after 72 hours.
You
can modify this in the registry.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Schedule
Add Value:
AtTaskMaxHours Data type: REG_DWORD
Decimal Value Data:
0.
A value of 0 indicates no limit, does not stop.
Values from 1 through 99 indicate the number of hours.
See Q226370 for bugs related to the Task Scheduler under NT4.
Other Task Scheduler options are stored in the registry
HKLM\SOFTWARE\Microsoft\SchedulingAgent\
"We don't wake up for less than $10,000 a day" - Linda
Evangelista
Related commands:
SOON - Schedule a command to run in the near future
CALL - Call one batch program from another.
JT - Win 2000 Task
Scheduler Command Line Utility
SchTasks - Task Scheduler
WMIC JOB - WMI access to scheduled tasks.
Scheduling Windows
2000’s Disk Defragmenter
Equivalent Linux BASH commands:
cron - Daemon to execute scheduled commands
crontab - Schedule a command to run at a
later time
watch - Execute/display a program periodically