Monday, January 3, 2011

SCHTASKS command.

Ref. Windows CMD commands

Create, delete, edit, list, start or stop a scheduled task.
Works on local or remote computers.
Syntax:

   SCHTASKS /Create [Connect_Options] create_options

   SCHTASKS /Delete [Connect_Options] /TN taskname [/F]

   SCHTASKS /Query  [Connect_Options] [/FO format] [/NH] [/V]

   SCHTASKS /Run [Connect_Options] /TN taskname
   SCHTASKS /End [Connect_Options] /TN taskname

   SCHTASKS /Change [Connect_Options] {[/RU username] [/RP password] [/TR taskrun]} /TN taskname

 Connect_Options:
     /S system                      #remote system (default is local)
    [/U username [/P password]]     #submit job under this name

 create_options:
    [/RU username [/RP password]]   #run job under this name
    /SC schedule [/MO modifier]     #When to run, see below
    [/D day]                        #day = MON,TUE,WED,THU,FRI,SAT,SUN
    [/M months]                     #month=JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC.
    [/I idletime]                   #1 - 999 minutes (ONIDLE task only)
    /TN taskname /TR taskrun        #Name and pathname for task
    /ST starttime                   #HH:MM:SS (24 hour)
    [/SD startdate] [/ED enddate]   #start and end date "dd/mm/yyyy"

 options:
    /F    Force delete, ignore warnings even if the task is currently runnning.
    /FO format  Output format: TABLE, LIST, CSV
    /NH   No header
    /V    Verbose output
 
Examples:
Create a task to run at 11 pm every weekday
SCHTASKS /Create /SC weekly /D MON,TUE,WED,THU,FRI /TN MyDailyBackup /ST 23:00:00 /TR c:\backup.cmd /RU MyDomain\MyLogin /RP MyPassword Now delete the task:
SCHTASKS /Delete /TN "MyDailyBackup" /f
 

No comments:

Post a Comment