schtasks create
Schedules a task. Windows commands reference
On Windows
Windows
schtasks /create /sc <scheduletype> /tn <taskname> /tr <taskrun> [/s <computer> [/u [<domain>\]<user> [/p <password>]]] [/ru {[<domain>\]<user> | system}] [/rp <password>] [/mo <modifier>] [/d <day>[,<day>...] | *] [/m <month>[,<month>...]] [/i <idletime>] [/st <starttime>] [/ri <interval>] [{/et <endtime> | /du <duration>} [/k]] [/sd <startdate>] [/ed <enddate>] [/it] [/np] [/z] [/xml <xmlfile>] [/v1] [/f] [/rl <level>] [/delay <delaytime>] [/hresult]
To schedule a security script, Sec.vbs, to run every 20 minutes, type
schtasks /create /sc minute /mo 20 /tn "Security Script" /tr \\central\data\scripts\sec.vbsIdentify/scSpecifies the schedule type. Windows commands reference/moSpecifies how often the task runs within its schedule type. Windows commands reference/tnSpecifies a name for the task. Windows commands reference/trSpecifies the program or command that the task runs. Windows commands referenceMatches documented abuse: Execute (T1053.005)
To schedule a security script, Sec.vbs, to run on the local computer every 100 minutes between 5:00 P.M. and 7:59 A.M. each day, type
schtasks /create /tn "Security Script" /tr sec.vbs /sc minute /mo 100 /st 17:00 /et 08:00 /kIdentify/tnSpecifies a name for the task. Windows commands reference/trSpecifies the program or command that the task runs. Windows commands reference/scSpecifies the schedule type. Windows commands reference/moSpecifies how often the task runs within its schedule type. Windows commands reference/stSpecifies the start time for the task, using the 24-hour time format, HH:mm. Windows commands reference/etSpecifies the time of day that a minute or hourly task schedule ends in \ 24-hour format. Windows commands reference/kStops the program that the task runs at the time specified by /et or /du. Windows commands referenceMatches documented abuse: Execute (T1053.005)
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 MyApp /tr c:\apps\myapp.exeIdentify/scSpecifies the schedule type. Windows commands reference/moSpecifies how often the task runs within its schedule type. Windows commands reference/sdSpecifies the date on which the task schedule starts. Windows commands reference/tnSpecifies a name for the task. Windows commands reference/trSpecifies the program or command that the task runs. Windows commands referenceMatches documented abuse: Execute (T1053.005)
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.exeIdentify/scSpecifies the schedule type. Windows commands reference/stSpecifies the start time for the task, using the 24-hour time format, HH:mm. Windows commands reference/tnSpecifies a name for the task. Windows commands reference/trSpecifies the program or command that the task runs. Windows commands referenceTo 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:00Identify/tnSpecifies a name for the task. Windows commands reference/trSpecifies the program or command that the task runs. Windows commands reference/scSpecifies the schedule type. Windows commands reference/moSpecifies how often the task runs within its schedule type. Windows commands reference/stSpecifies the start time for the task, using the 24-hour time format, HH:mm. Windows commands reference/duSpecifies a maximum length of time for a minute or hourly schedule in \ 24-hour format. Windows commands referenceMatches documented abuse: Execute (T1053.005)
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/2021Identify/tnSpecifies a name for the task. Windows commands reference/trSpecifies the program or command that the task runs. Windows commands reference/scSpecifies the schedule type. Windows commands reference/stSpecifies the start time for the task, using the 24-hour time format, HH:mm. Windows commands reference/edSpecifies the date on which the schedule ends. Windows commands referenceTo 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:00Identify/tnSpecifies a name for the task. Windows commands reference/trSpecifies the program or command that the task runs. Windows commands reference/scSpecifies the schedule type. Windows commands reference/moSpecifies how often the task runs within its schedule type. Windows commands reference/sdSpecifies the date on which the task schedule starts. Windows commands reference/stSpecifies the start time for the task, using the 24-hour time format, HH:mm. Windows commands referenceMatches documented abuse: Execute (T1053.005)
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 /itIdentify/tnSpecifies a name for the task. Windows commands reference/trSpecifies the program or command that the task runs. Windows commands reference/scSpecifies the schedule type. Windows commands reference/moSpecifies how often the task runs within its schedule type. Windows commands reference/itSpecifies to run the scheduled task only when the run as user (the user account under which the task runs) is logged on to the computer. Windows commands referenceMatches documented abuse: Execute (T1053.005)
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 Admin01Identify/tnSpecifies a name for the task. Windows commands reference/trSpecifies the program or command that the task runs. Windows commands reference/scSpecifies the schedule type. Windows commands reference/moSpecifies how often the task runs within its schedule type. Windows commands reference/sSpecifies the name or IP address of a remote computer (with or without backslashes). Windows commands reference/uRuns this command with the permissions of the specified user account. Windows commands referenceMatches documented abuse: Execute (T1053.005)
To schedule a task to run every other Friday, type
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc weekly /mo 2 /d FRIIdentify/tnSpecifies a name for the task. Windows commands reference/trSpecifies the program or command that the task runs. Windows commands reference/scSpecifies the schedule type. Windows commands reference/moSpecifies how often the task runs within its schedule type. Windows commands reference/dSpecifies how often the task runs within its schedule type. Windows commands referenceMatches documented abuse: Execute (T1053.005)
To schedule the MyApp program to run on the first day of every month, type
schtasks /create /tn MyApp /tr myapp.exe /sc monthlyIdentify/tnSpecifies a name for the task. Windows commands reference/trSpecifies the program or command that the task runs. Windows commands reference/scSpecifies the schedule type. Windows commands referenceTo schedule the MyApp program to run every three months, type
schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /mo 3Identify/tnSpecifies a name for the task. Windows commands reference/trSpecifies the program or command that the task runs. Windows commands reference/scSpecifies the schedule type. Windows commands reference/moSpecifies how often the task runs within its schedule type. Windows commands referenceMatches documented abuse: Execute (T1053.005)
Show 30 options
/sc <scheduletype>Specifies the schedule type. The valid values include:
- MINUTE - Specifies the number of minutes before the task should run.
- HOURLY - Specifies the number of hours before the task should run.
- DAILY - Specifies the number of days before the task should run.
- WEEKLY Specifies the number of weeks before the task should run.
- MONTHLY - Specifies the number of months before the task should run.
- ONCE - Specifies that that task runs once at a specified date and time.
- ONSTART - Specifies that the task runs every time the system starts. You can specify a start date, or run the task the next time the system starts.
- ONLOGON - Specifies that the task runs whenever a user (any user) logs on. You can specify a date, or run the task the next time the user logs on.
- ONIDLE - Specifies that the task runs whenever the system is idle for a specified period of time. You can specify a date, or run the task the next time the system is idle.
- ONEVENT - Specifies that the task runs based on an event that matches information from the system event log including the EventID./tn <taskname>Specifies a name for the task. Each task on the system must have a unique name and must conform to the rules for file names, not exceeding 238 characters. Use quotation marks to enclose names that include spaces. To store your scheduled task in a different folder, run /tn <folder name\task name>./tr <Taskrun>Specifies the program or command that the task runs. Type the fully qualified path and file name of an executable file, script file, or batch file. The path name must not exceed 262 characters. If you don't add the path, schtasks assumes that the file is in the <systemroot>\System32 directory./s <computer>Specifies the name or IP address of a remote computer (with or without backslashes). The default is the local computer./u [<domain>]Runs this command with the permissions of the specified user account. The default is the permissions of the current user of the local computer. The /u and /p parameters are valid only when you use /s. The permissions of the specified account are used to schedule the task and to run the task. To run the task with the permissions of a different user, use the /ru parameter. The user account must be a member of the Administrators group on the remote computer. Also, the local computer must be in the same domain as the remote computer, or must be in a domain that is trusted by the remote computer domain./p <password>Specifies the password of the user account specified in the /u parameter. If you use the /u parameter without the /p parameter or the password argument, schtasks will prompt you for a password. The /u and /p parameters are valid only when you use /s./ru {[<domain>\]<user> | system}Runs the task with permissions of the specified user account. By default, the task runs with the permissions of the current user of the local computer, or with the permission of the user specified by the /u parameter, if one is included. The /ru parameter is valid when scheduling tasks on local or remote computers. The valid options include:
- Domain - Specifies an alternate user account.
- System - Specifies the local System account, a highly privileged account used by the operating system and system services./rp <password>Specifies the password for the existing user account, or the user account specified by the /ru parameter. If you don't use this parameter when specifying a user account, SchTasks.exe will prompt you for the password next time you sign in. Don't use the /rp parameter for tasks that run with System account credentials (/ru System). The System account doesn't have a password and SchTasks.exe doesn't prompt for one./mo <modifiers>Specifies how often the task runs within its schedule type. The valid options include:
- MINUTE - Specifies that the task runs every <n> minutes. You can use any value between 1 - 1439 minutes. By default, this is 1 minute.
- HOURLY - Specifies that the task runs every <n> hours. You can use any value between 1 - 23 hours. By default, this is 1 hour.
- DAILY - Specifies that the task runs every <n> days. You can use any value between 1 - 365 days. By default, this is 1 day.
- WEEKLY - Specifies that the task runs every <n> weeks. You can use any value between 1 - 52 weeks. By default, this is 1 week.
- MONTHLY - Specifies that the task runs every <n> months. You can use any of the following values:
- A number between 1 - 12 months
- LASTDAY - To run the task on the last day of the month
- FIRST, SECOND, THIRD, or FOURTH along with the /d <day> parameter - Specifies the particular week and day to run the task. For example, on the third Wednesday of the month.
- ONCE - Specifies that the task runs once.
- ONSTART - Specifies that the task runs at startup.
- ONLOGON - Specifies that the task runs when the user specified by the /ru parameter logs on. …/d DAY[,DAY...]Specifies how often the task runs within its schedule type. The valid options include:
- WEEKLY - Specifies that the task runs weekly by providing a value between 1-52 weeks. Optionally, you can also add a specific day of the week by adding a value of MON - SUN or a range of [MON - SUN...]).
- MONTHLY - Specifies that the task runs weekly each month by providing a value of FIRST, SECOND, THIRD, FOURTH, LAST. Optionally, you can also add a specific day of the week by adding a value of MON - SUN or by providing a number between 1 - 12 months. If you use this option, you can also add a specific day of the month, by providing a number between 1-31.
NOTE: The date value of 1 - 31 is valid only without the /mo parameter, or if the /mo parameter is monthly (1 - 12). The default is day 1 (the first day of the month)./m MONTH[,MONTH...]Specifies a month or months of the year during which the scheduled task should run. The valid options include JAN - DEC and * (every month). The /m parameter is valid only with a MONTHLY schedule. It's required when the LASTDAY modifier is used. Otherwise, it's optional and the default value is * (every month)./i <Idletime>Specifies how many minutes the computer is idle before the task starts. A valid value is a whole number from 1 to 999. This parameter is valid only with an ONIDLE schedule, and then it's required./st <Starttime>Specifies the start time for the task, using the 24-hour time format, HH:mm. The default value is the current time on the local computer. The /st parameter is valid with MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, and ONCE schedules. It's required for a ONCE schedule./ri <interval>Specifies the repetition interval for the scheduled task, in minutes. This isn't applicable for schedule types: MINUTE, HOURLY, ONSTART, ONLOGON,ONIDLE, and ONEVENT. Valid range is 1 - 599940 (599940 minutes = 9999 hours). If either the /et or /du parameters are specified, the default is 10 minutes./et <endtime>Specifies the time of day that a minute or hourly task schedule ends in <HH:MM> 24-hour format. After the specified end time, schtasks does not start the task again until the start time recurs. By default, task schedules have no end time. This parameter is optional and valid only with a MINUTE or HOURLY schedule./du <duration>Specifies a maximum length of time for a minute or hourly schedule in <HHHH:MM> 24-hour format. After the specified time elapses, schtasks does not start the task again until the start time recurs. By default, task schedules have no maximum duration. This parameter is optional and valid only with a MINUTE or HOURLY schedule./kStops the program that the task runs at the time specified by /et or /du. Without /k, schtasks doesn't start the program again after it reaches the time specified by /et or /du nor does it stop the program if it's still running. This parameter is optional and valid only with a MINUTE or HOURLY schedule./sd <Startdate>Specifies the date on which the task schedule starts. The default value is the current date on the local computer. The format for Startdate varies with the locale selected for the local computer in Regional and Language Options. Only one format is valid for each locale. The valid date formats include (be sure to choose the format most similar to the format selected for Short date in Regional and Language Options on the local computer):
- <MM>// - Specifies to use month-first formats, such as English (United States) and Spanish (Panama).
- <DD>// - Specifies to use day-first formats, such as Bulgarian and Dutch (Netherlands).
- <YYYY>// - Specifies to use for year-first formats, such as Swedish and French (Canada)./ed <Enddate>Specifies the date on which the schedule ends. This parameter is optional. It isn't valid in a ONCE, ONSTART, ONLOGON, ONIDLE, or ONEVENT schedule. By default, schedules have no ending date. The default value is the current date on the local computer. The format for Enddate varies with the locale selected for the local computer in Regional and Language Options. Only one format is valid for each locale. The valid date formats include (be sure to choose the format most similar to the format selected for Short date in Regional and Language Options on the local computer):
- <MM>// - Specifies to use month-first formats, such as English (United States) and Spanish (Panama).
- <DD>// - Specifies to use day-first formats, such as Bulgarian and Dutch (Netherlands).
- <YYYY>// - Specifies to use for year-first formats, such as Swedish and French (Canada)./ec <channelname>Specifies the event channel name triggered by the ONEVENT schedule type that matches a system event log criteria./itSpecifies to run the scheduled task only when the run as user (the user account under which the task runs) is logged on to the computer. This parameter has no effect on tasks that run with system permissions or tasks that already have the interactive-only property set. You can't use a change command to remove the interactive-only property from a task. By default, run as user is the current user of the local computer when the task is scheduled or the account specified by the /u parameter, if one is used. However, if the command includes the /ru parameter, then the run as user is the account specified by the /ru parameter./npNo password is stored. The task runs non-interactively as the given user. Only local resources are available./zSpecifies to delete the task upon the completion of its schedule./xml <xmlfile>Creates a task specified in the XML file. Can be combined with the /ru and /rp parameters, or with the /rp parameter by itself if the XML file already contains the user account information./v1Creates a task visible to pre-Vista operating systems. This is not compatible with the /XML parameter./fSpecifies to create the task and suppress warnings if the specified task already exists./rl <level>Specifies the Run Level for the job. Acceptable values are LIMITED (scheduled tasks will be ran with the least level of privileges, such as Standard User accounts) and HIGHEST (scheduled tasks will be ran with the highest level of privileges, such as Superuser accounts). The default value is Limited./delay <delaytime>Specifies the wait time to delay running the task after it's triggered in mmmm:ss format. This is only valid for the ONSTART, ONLOGON, and ONEVENT schedule types./hresultSpecifies the process exit code to be in HRESULT format./?Displays help at the command prompt.