Microsoft KB Archive/313565

= How To Use the AT Command to Schedule Tasks =

Article ID: 313565

Article Last Modified on 10/30/2006

-

APPLIES TO


 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Professional Edition
 * Microsoft Small Business Server 2000 Standard Edition

-



This article was previously published under Q313565



IN THIS TASK

 * SUMMARY
 * Overview of the AT Command
 * How to Create a Scheduled Task
 * Examples
 * How to Cancel a Scheduled Task
 * Examples
 * How to View Scheduled Tasks
 * Examples
 * Troubleshooting
 * REFERENCES



SUMMARY
In Windows 2000, you can use the Task Scheduler tool in Control Panel to schedule tasks. You can also use the at command to schedule tasks manually. This article describes how to use the at command to create and to cancel scheduled tasks.

back to the top

Overview of the AT Command
You can use the at command to schedule a command, a script, or a program to run at a specified date and time. You can also use this command to view existing scheduled tasks.

To use the at command, the Task Scheduler service must be running, and you must be logged on as a member of the local Administrators group. When you use the at command to create tasks, you must configure the tasks so that they run in the same user account.

The at command uses the following syntax:

at \\ /interactive | /every:, ... /next: , ...

at \\ /delete | /delete /yes

The following list describes the parameters that you can use with the at command:
 *  : Use this parameter to specify a remote computer. If you omit this parameter, tasks are scheduled to run on the local computer.
 *  : Use this parameter to specify the time when the task is to run. Time is specified as :  based on the 24-hour clock. For example, 0:00 represents midnight and 20:30 represents 8:30 P.M.
 *  : Use this parameter to allow the task to interact with the desktop of the user who is logged on at the time the task runs.
 * /every: ,...: Use this parameter to schedule the task to run on the specified day or days of the week or month, for example, every Friday or the eighth day of every month. Specify  as one or more days of the week (use the following abbreviations: M,T,W,Th,F,S,Su) or one or more days of the month (use the numbers 1 through 31). Make sure that you use commas to separate multiple date entries. If you omit this parameter, the task is scheduled to run on the current day.
 * /next: ,...: Use this parameter to schedule the task to run on the next occurrence of the day (for example, next Monday). Specify  as one or more days of the week (use the following abbreviations: M,T,W,Th,F,S,Su) or one or more days of the month (use the numbers 1 through 31). Make sure that you use commas to separate multiple date entries. If you omit this parameter, the task is scheduled to run on the current day.
 *  : Use this parameter to specify the Windows 2000 command, the program (.exe or .com file), or the batch program (.bat or .cmd file) that you want to run. If the command requires a path as an argument, use the absolute path name (the entire path beginning with the drive letter). If the command is on a remote computer, use the Uniform Naming Convention (UNC) path name (\\ \ ). If the command is not an executable (.exe) file, you must precede the command with cmd /c, for example, cmd /c copy C:\*.* C:\temp.
 *  : Use this parameter to specify the identification number that is assigned to a scheduled task.
 * /delete: Use this parameter to cancel a scheduled task. If you omit the id parameter, all scheduled tasks on the computer are canceled.
 * /yes: Use this parameter to force a yes answer to all queries from the system when you cancel scheduled tasks. If you omit this parameter, you are prompted to confirm the cancellation of a task.

Note When you use the at command, the scheduled task is run by using the credentials of the system account.

back to the top

How to Create a Scheduled Task
 Click Start, point to Programs, point to Accessories, and then click Command Prompt. At the command prompt, type the following line, and then press ENTER to display a list of currently running services:

net start

If Task Scheduler is not displayed in the list, type the following line, and then press ENTER:

net start &quot;task scheduler&quot;

 At the command prompt, type the following line (use the parameters that are appropriate to your situation), and then press ENTER:

at \\ /interactive | /every:, ... /next: , ...



back to the top

Examples
 To copy all files from the Documents folder to the MyDocs folder at midnight, type the following line, and then press ENTER:

at 00:00 cmd /c copy C:\Documents\*.* C:\MyDocs

 To back up the Products server at 11:00 P.M. each weekday, create a batch file that contains the backup commands (for example, Backup.bat), type the following line, and then press ENTER to schedule the backup:

at \\products 23:00 /every:M,T,W,Th,F backup

 To schedule a net share command to run on the Sales server at 6:00 A.M. and to redirect the listing to the Sales.txt file in the shared Reports folder on the Corp server, type the following line, and then press ENTER:

at \\sales 06:00 cmd /c &quot;net share reports=d:\Documents\reports >> \\corp\reports\sales.txt&quot;

</li></ul>

back to the top

How to Cancel a Scheduled Task
 Click Start, point to Programs, point to Accessories, and then click Command Prompt.</li> At the command prompt, type the following line, and then press ENTER to display a list of currently running services:

net start

If Task Scheduler is not displayed in the list, type the following line, and then press ENTER:

net start &quot;task scheduler&quot;

</li> At the command prompt, type the following line (use the parameters that are appropriate to your situation), and then press ENTER:

at \\ /delete | /delete /yes

</li></ol>

back to the top

Examples

 * To cancel all tasks that are scheduled on the local computer, type at /delete, and then press ENTER.
 * To cancel the task ID 8 on a computer that is named &quot;MyServer,&quot; type at \\MyServer 8 /delete, and then press ENTER.

back to the top

How to View Scheduled Tasks
To view the tasks that you created by using the at command, follow these steps:  Click Start, point to Programs, point to Accessories, and then click Command Prompt.</li> At the command prompt, type the following line, and then press ENTER to display a list of currently running services:

net start

If Task Scheduler is not displayed in the list, type the following line, and then press ENTER:

net start &quot;task scheduler&quot;

</li> At the command prompt, do one of the following steps: <ul> To view a list of tasks that you scheduled by using the at command, type the following line, and then press ENTER:

at \\

-or-

</li> To view a specific scheduled task, type the following line, and then press ENTER:

at \\

</li></ul> </li></ol>

back to the top

Examples

 * To view all scheduled tasks on the local computer, type at, and then press ENTER.
 * To view all scheduled tasks on a computer named &quot;Support,&quot; type at \\support, and then press ENTER.
 * To view the task ID 18 on the local computer, type at 18, and then press ENTER.

back to the top

Troubleshooting
<ul> When you type at to view a list of scheduled tasks, some (or all) of the scheduled tasks that you created by using the at command are not listed.

This behavior can occur if you modified the tasks in the Scheduled Tasks folder after you used the at command to create the task. When you use the at command to schedule a task, the task is displayed in the Scheduled Tasks folder in Control Panel. You can view or modify the task. However, if you modify the task, when you use the at command, you cannot view the task.

To work around this behavior, view or modify the task in the Scheduled Tasks folder in Control Panel.For additional information about this behavior, click the article number below to view the article in the Microsoft Knowledge Base:

220149 AT Tasks Cannot Be Viewed Using the Task Scheduler Tool

</li> When you use the at command to schedule a task, the task does not run at the specified time or date.

This behavior can occur if one of the following conditions are true: <ul> The command syntax is incorrect.

After you schedule a task, type at to confirm that the syntax is correct. If the information that is displayed under Command Line is incorrect, cancel the task, and then recreate it.

-or-</li> You schedule a task to run a command that is not an .exe file.

The at command does not automatically load cmd (the command interpreter) before it runs commands. Unless you are running an .exe file, you must load Cmd.exe at the beginning of the command, for example, at cmd /c dir > c:\test.txt .</li></ul> </li></ul>

For additional information about troubleshooting the AT command, click the article numbers below to view the articles in the Microsoft Knowledge Base:

142040 Troubleshooting AT Command Using /k Switch

121562 Applications Started with AT Are Not Interactive

back to the top

<div class="references_section">