Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,720 Programmers for FREE! Ask your question and get quick answers from experts. There are 2,148 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Windows Task Schedular via command line : SCHTASKS

 
Reply to this topicStart new topic

> Windows Task Schedular via command line : SCHTASKS

no2pencil
Group Icon



post 12 Feb, 2008 - 08:15 AM
Post #1


Windows Task Schedular via command line : SCHTASKS

Using this command, you can create, delete, edit, list, start or stop a scheduled task. This command also works on local or remote computers.

The command syntax is as follows:

CODE

   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


For monthly schedules, you must give the day as the number of the day. The default is one, & obviously the max is the amount of days in that month.

To prompt for the password, specify /RP * or /RP none

The User Account under which the Schedule service runs may require specific file access permissions, user permissions, and drive mappings.

For the system account, /RU username can be written as "", "NT AUTHORITY\SYSTEM" or "SYSTEM", a Password is not required.

The schedule frequency is accessed via the /SC switch. The SC is short for schedule. Schedules can be set to time frames of minute, hourly, daily, weekly, or montly. You can also specify once, onstart, onlogon, or onidle for running the schedule once.

The /MO switch is short for modifier, & allows finer, more specific control.

QUOTE

MINUTE: 1 - 1439 minutes.
HOURLY: 1 - 23 hours.
DAILY: 1 - 365 days.
WEEKLY: weeks 1 - 52.
ONCE: No modifiers.
ONSTART: No modifiers.
ONLOGON: No modifiers.
ONIDLE: No modifiers.
MONTHLY: 1 - 12, or FIRST, SECOND, THIRD, FOURTH, LAST, LASTDAY.


Task Scheduler options are stored in the registry key HKLM\SOFTWARE\Microsoft\SchedulingAgent\

Examples:

Create a daily task to run at 11 pm
CODE

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:
CODE

SCHTASKS /Delete /TN "MyDailyBackup" /f


The SCHTASKS is equivalent to the Unix crontab.
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!


Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 9/8/08 09:29AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month