at command using

at command to schedule a command, a script, or a program to run at a specified date and time.

The at command  syntax:
at \\computername time /interactive | /every:date,… /next:date,… command
at \\computername id /delete | /delete/yesThe following list describes the parameters that you

Parameters
\\computername: Use this parameter to specify a remote computer. If you omit this parameter, tasks are scheduled to run on the local computer.
time: Use this parameter to specify the time when the task is to run. Time is specified as hours:minutes based on the 24-hour clock. For example, 0:00 represents midnight and 20:30 represents 8:30 P.M.
/interactive: 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:date,…: 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 date 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:date,…: Use this parameter to schedule the task to run on the next occurrence of the day (for example, next Monday). Specify date 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.
command: 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 (\\ServerName\ShareName). 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.
id: 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.

Creating a Scheduled Task
type netstart tocheck taskscheduler running,if not netstart “task scheduler”
 
Eg: c:\> net start
SSDP Discovery Service
 System Event Notification
 System Restore Service
 Task Scheduler
 TCP/IP NetBIOS Helper
 Telephony
 Terminal Services
then type
at \\computername time /interactive | /every:date,… /next:date,… command

eg:at /every:W,F 08:45 move c:\test\mydumplog d:\mydump

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:\MyDocsTo 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 backupTo 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 “net share reports=d:\Documents\reports >> \\corp\reports\sales.txt”

Cancelig a Scheduled Task
at \\computername id /delete | /delete/yes

Note:
At does not automatically load Cmd.exe, the command interpreter, before running commands. If you are not running an executable (.exe) file, you must explicitly load Cmd.exe at the beginning of the command as follows:

cmd /c dir > c:\test.out

Commands scheduled with at run as background processes. Output is not displayed on the computer screen. To redirect output to a file, use the redirection symbol (>). If you redirect output to a file, you need to use the escape symbol (^) before the redirection symbol, whether you are using at at the command line or in a batch file. For example, to redirect output to Output.text

eg:at 14:45 c:\test.bat ^>c:\output.txt

other examples
To schedule a net share command to run on the Corp server at 8:00 A.M. and redirect the listing to the Maintenance server, in the Reports shared directory, and the Corp.txt file, type:

at \\corp 08:00 cmd /c “net share reports=d:\marketing\reports >> \\maintenance\reports\corp.txt”

To back up the hard drive of the Marketing server to a tape drive at midnight every five days, create a batch program called Archive.cmd, which contains the backup commands, and then schedule the batch program to run, type:

at \\marketing 00:00 /every:5,10,15,20,25,30 archive

To cancel all commands scheduled on the current server, clear the at schedule information as follows:

at /delete

To run a command that is not an executable (that is, .exe) file, precede the command with cmd /c to load Cmd.exe as follows:

cmd /c dir > c:\test.out

Advertisements

Posted on September 27, 2011, in General, Uncategorized, Windows. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: