Batch Files - Collection
Batch Files - Collection
This command is
available for backwards compatibility with NT 4 but has been superseded by
SCHTASKS.
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.
Monday = m
Tuesday = t
Wednesday = w
Thursday = th
Friday = f
Saturday = s
Sunday = su
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
::::::::::::
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.
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.
The User Account under which the Schedule service runs may require specific file access
permissions, user permissions and drive mappings.
Here's how to check if a user account has sufficent rights for a particular task:
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:
• The PATH
• Environment variables (particularly TEMP).
• Drive mappings - you can add these by putting appropriate NET USE...
commands at the beginning of your batch file.
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.
HKLM\SOFTWARE\Microsoft\SchedulingAgent\
"We don't wake up for less than $10,000 a day" - Linda Evangelista
Related commands: