Windows2012. 5. 3. 13:26

출처 : http://ss64.com/nt/at.html

AT.exe

Schedule a command or batch file to run on a computer at a specific date and time.

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. 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

In other locales the day(s) may be different letters:
Italian: L,MA,ME,g,v,s,d
German: M, T, W, Th, F, S, Su
French: L, M, Me, J, V, S, D

Examples:

Run a command every day

AT 23:30 /EVERY:m,t,w,th,f,s,su c:\backups\every_day.cmd

Run a command every Friday

AT 23:30 /EVERY:f c:\backups\weekly.cmd

Remove all scheduled AT jobs

AT /delete /yes

Run a command this evening (once only)

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.

Other requirements

The "Task Scheduler" service must be running to use the AT command.

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. For most purposes the SchTasks command is a better choice than AT.

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 multiple commands into a 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:

C:\> AT 14:32 /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:

  • 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.

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:

SOON - Schedule a command to run in the near future
CALL - Call one batch program from another.
Powershell: To schedule a PS task call Powershell.exe
JT.exe (Microsoft FTP) - Manage the Task Scheduler from the command line
SchTasks - Task Scheduler
WMIC JOB - WMI access to scheduled tasks.
Equivalent bash command (Linux): crontab - Schedule a command to run at a later time

Posted by 배움나눔