Posted On 2007-07-11 by FortyPoundHead
Keywords: Command Reference
Tags: Windows Commandline Windows
Rating: / 5.00
Schedule a batch file to run on a computer at a specific date and time.
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]]
\\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.
/next:day(s) : Run the command on the next occurrence of the day.
"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
Running a command every day
AT 23:30 /EVERY:m,t,w,th,f,s,su c:\backups\every_day.cmd
Running a command every Friday
AT 23:30 /EVERY:f c:\backups\weekly.cmd
Running a command this evening (once only)
AT 23:30 /NEXT: c:\backups\today.cmd
Rights needed to issue an AT command
By default only an Administrator can issue an AT command, and 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.
Be aware that a global workgroup setup with 'Local Administrator' rights would allow every member full control of not only their own workstation but EVERY workstation on the network.
To setup a workstation so that anyone logging in will have local admin rights (to that machine only) use the command:
NET LOCALGROUP "Administrators" INTERACTIVE /add
NET LOCALGROUP "Power Users" INTERACTIVE /add
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 has 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
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
Control Panel, Services, SCHEDULER, Startup, Logon As...
If you have Internet Explorer 4 or greater the User Account is selected under
SCHEDULED TASKS, Advanced, AT Service Account.
You also need to *stop* and restart the service before the change in UserAccount will take effect.
Don't try to pass more than one command into AT, put everything you want to achieve in one batch file and then just call that batch file from AT.
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:
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.
The Scheduled Tasks GUI
Scheduled tasks are available with IE 4.0 + and extend the functionality of AT, particularly in the area of permissions.
The Task Scheduler option adds an extra folder (and extra menu options) to Windows Explorer.
Task Scheduler options are stored in the registry
See Q226370 for bugs related to the Task Scheduler. Also note that using the GUI to edit a Scheduled Task (as opposed to editing at the command line) you are required to supply the password for the user account under which the task will run. (In other words the task can no longer run under the system account)
Comments On This Post
No comments on this post yet!
Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.
Or you can drop a note to the administrators if you're not sure where you should post.