text stringlengths 0 4.23k |
|---|
Examples |
To schedule the MyApp program to run every five hours, beginning on the first day of March 2002, type: |
schtasks /create /sc hourly /mo 5 /sd 03/01/2002 /tn My App /tr c:\apps\myapp.exe |
In this example, the local computer uses the English (Zimbabwe) option in Regional and Language Options, so the format for the start date is MM/DD/YYYY (03/01/2002). |
To schedule the MyApp program to run hourly, beginning at five minutes past midnight, type: |
schtasks /create /sc hourly /st 00:05 /tn MyApp /tr c:\apps\myapp.exe |
To schedule the MyApp program to run every 3 hours, for 10 hours total, type: |
schtasks /create /tn MyApp /tr myapp.exe /sc hourly /mo 3 /st 00:00 /du 0010:00 |
In this example, the task runs at 12:00 A.M., 3:00 A.M., 6:00 A.M., and 9:00 A.M. Because the duration is 10 hours, the task isn't run again at 12:00 P.M. Instead, it starts again at 12:00 A.M. the next day. Also, because the program runs for just a few minutes, the /k parameter, which stops the program if it's still running when the duration expires, isn't necessary. |
To schedule a task to run every <n> days |
<n> |
In a daily schedule, the /sc daily parameter is required. The /mo (modifier) parameter is optional and specifies the number of days between each run of the task. The default value for /mo is 1 (every day). |
Examples |
To schedule the MyApp program to run once a day, every day, at 8:00 A.M. until December 31, 2021, type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc daily /st 08:00 /ed 31/12/2021 |
In this example, the local computer system is set to the English (United Kingdom) option in Regional and Language Options, so the format for the end date is DD/MM/YYYY (31/12/2021). Additionally, because this example doesn't include the /mo parameter, the default interval of 1 is used to run the command every day. |
To schedule the MyApp program to run every twelve days at 1:00 P.M. (13:00) beginning on December 31, 2021, type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc daily /mo 12 /sd 12/31/2002 /st 13:00 |
In this example, the system is set to the English (Zimbabwe) option in Regional and Language Options, so the format for the end date is MM/DD/YYYY (12/31/2021). |
To schedule a security script, Sec.vbs, to run every 70 days, type: |
schtasks /create /tn "Security Script" /tr sec.vbs /sc daily /mo 70 /it |
In this example, the /it parameter is used to specify that the task runs only when the user under whose account the task runs is logged onto the computer. Because the task runs with the permissions of a specific user account, this task only runs when that user is logged on. |
Note |
To identify tasks with the interactive-only (/it) property, use a verbose query (/query /v). In a verbose query display of a task with /it, the Logon Mode field has a value of Interactive only. |
To schedule a task to run every <n> weeks |
<n> |
In a weekly schedule, the /sc weekly parameter is required. The /mo (modifier) parameter is optional and specifies the number of weeks between each run of the task. The default value for /mo is 1 (every week). |
Weekly schedules also have an optional /d parameter to schedule the task to run on specified days of the week, or on all days (). The default is MON (Monday). The every day () option is equivalent to scheduling a daily task. |
Examples |
To schedule the MyApp program to run on a remote computer every six weeks, type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc weekly /mo 6 /s Server16 /u Admin01 |
Because this example leaves out the /d parameter, the task runs on Mondays. This example also uses the /s parameter to specify the remote computer and the /u parameter to run the command with the permissions of the user's Administrator account. Additionally, because the /p parameter is left out, SchTasks.exe prompts the user for the Administrator account password, and because the command is run remotely, all paths in the command, including the path to MyApp.exe, refer to paths on the remote computer. |
To schedule a task to run every other Friday, type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc weekly /mo 2 /d FRI |
This example uses the /mo parameter to specify the two-week interval and the /d parameter to specify the day of the week. To schedule a task that runs every Friday, leave out the /mo parameter or set it to 1. |
To schedule a task to run every <n> months |
<n> |
In this schedule type, the /sc monthly parameter is required. The /mo (modifier) parameter, which specifies the number of months between each run of the task, is optional and the default is 1 (every month). This schedule type also has an optional /d parameter to schedule the task to run on a specified date of the month. The default is 1 (the first day of the month). |
Examples |
To schedule the MyApp program to run on the first day of every month, type: |
schtasks /create /tn MyApp /tr myapp.exe /sc monthly |
The default value for both the /mo (modifier) parameter and the /d (day) parameter is 1, so you don't need to use either of those parameters for this example. |
To schedule the MyApp program to run every three months, type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /mo 3 |
This example uses the /mo parameter to specify an interval of 3 months. |
To schedule the MyApp program to run every other month on the 21st day of the month at midnight for a year, from July 2, 2002 to June 30, 2003, type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /mo 2 /d 21 /st 00:00 /sd 2002/07/01 /ed 2003/06/30 |
This example uses the /mo parameter to specify the monthly interval (every two months), the /d parameter to specify the date, the /st parameter to specify the time, and the /sd and /ed parameters to specify the start date and end date, respectively. Also in this example, the local computer is set to the English (South Africa) option in Regional and Language Options, so the dates are specified in the local format, YYYY/MM/DD. |
To schedule a task to run on a specific day of the week |
The day of the week schedule is a variation of the weekly schedule. In a weekly schedule, the /sc weekly parameter is required. The /mo (modifier) parameter is optional and specifies the number of weeks between each run of the task. The default value for /mo is 1 (every week). The /d parameter, which is optional, schedules the task to run on specified days of the week, or on all days (*). The default is MON (Monday). The every day option (/d *) is equivalent to scheduling a daily task. |
(/d *) |
Examples |
To schedule the MyApp program to run every week on Wednesday, type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc weekly /d WED |
This example uses the /d parameter to specify the day of the week. Because the command leaves out the /mo parameter, the task runs every week. |
To schedule a task to run on Monday and Friday of every eighth week, type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc weekly /mo 8 /d MON,FRI |
This example uses the /d parameter to specify the days and the /mo parameter to specify the eight-week interval. |
To schedule a task to run on a specific week of the month |
In this schedule type, the /sc monthly parameter, the /mo (modifier) parameter, and the /d (day) parameter are required. The /mo (modifier) parameter specifies the week on which the task runs. The /d parameter specifies the day of the week. You can specify only one day of the week for this schedule type. This schedule also has an optional /m (month) parameter that lets you schedule the task for particular months or every month (*). The default for the /m parameter is every month (*). |
Examples |
To schedule the MyApp program to run on the second Sunday of every month, type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /mo SECOND /d SUN |
This example uses the /mo parameter to specify the second week of the month and the /d parameter to specify the day. |
To schedule the MyApp program to run on the first Monday in March and September, type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /mo FIRST /d MON /m MAR,SEP |
This example uses the /mo parameter to specify the first week of the month and the /d parameter to specify the day. It uses the /m parameter to specify the month, separating the month arguments with a comma. |
To schedule a task to run on a specific day each month |
In this schedule type, the /sc monthly parameter and the /d (day) parameter are required. The /d parameter specifies a date of the month (1 - 31), not a day of the week, and you can specify only one day in the schedule. The /m (month) parameter is optional, with the default being every month (), while the /mo (modifier) parameter isn't valid with this schedule type. |
Schtasks.exe won't let you schedule a task for a date that's not in a month specified by the /m parameter. For example, trying to schedule the 31st day of February. However, if you don't use the /m parameter, and schedule a task for a date that doesn't appear in every month, then the task won't run in the shorter months. To schedule a task for the last day of the month, use the last day schedule type. |
Examples |
To schedule the MyApp program to run on the first day of every month, type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly |
Because the default modifier is none (no modifier), this command uses the default day of 1, and the default month of every month, without requiring any additional parameters. |
To schedule the MyApp program to run on May 15 and June 15 at 3:00 P.M. (15:00), type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /d 15 /m MAY,JUN /st 15:00 |
This example uses the /d parameter to specify the date and the /m parameter to specify the months. It also uses the /st parameter to specify the start time. |
To schedule a task to run on the last day of a month |
In the last day schedule type, the /sc monthly parameter, the /mo LASTDAY (modifier) parameter, and the /m (month) parameter are required. The /d (day) parameter isn't valid. |
Examples |
To schedule the MyApp program to run on the last day of every month, type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /mo lastday /m * |
This example uses the /mo parameter to specify the last day and the /m parameter with the wildcard character (*) to indicate that the program runs every month. |
To schedule the MyApp program to run on the last day of February and the last day of March at 6:00 P.M., type: |
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /mo lastday /m FEB,MAR /st 18:00 |
This example uses the /mo parameter to specify the last day, the /m parameter to specify the months, and the /st parameter to specify the start time. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.