Schtasks
Updated: January 21, 2005
To view the command syntax, click the following command:
schtasks create
Schtasks uses different parameter combinations for each schedule type. To see the combined syntax for creating tasks or to see the syntax for creating a task with a particular schedule type, click one of the following options.
- Combined syntax and parameter descriptions
- To schedule a task that runs every N minutes
- To schedule a task that runs every N hours
- To schedule a task that runs every N days
- To schedule a task that runs every N weeks
- To schedule a task that runs every N months
- To schedule a task that runs on a specific day of the week
- To schedule a task that runs on a specific week of the month
- To schedule a task that runs on a specific date each month
- To schedule a task that runs on a the last day of a month
- To schedule a task that runs once
- To schedule a task that runs every time the system starts
- To schedule a task that runs when a user logs on
- To schedule a task that runs when the system is idle
- To schedule a task that runs now
- To schedule a task that runs with different permissions
- To schedule a task that runs with system permissions
- To schedule a task that runs more than one program
- To schedule a task that runs on a remote computer
Combined syntax and parameter descriptions
Syntax
Parameters
To schedule a task that runs every N minutes
Minute Schedule Syntax
Remarks
Examples
To schedule a task that runs every 20 minutes
Because the command does not include a starting date or time, the task starts 20 minutes after the command completes, and runs every 20 minutes thereafter whenever the system is running. Notice that the security script source file is located on a remote computer, but that the task is scheduled and executes on the local computer.
schtasks /create /sc minute /mo 20 /tn "Security Script" /tr \\central\data\scripts\sec.vbs
To schedule a task that runs every 100 minutes during non-business hours
schtasks /create /tn "Security Script" /tr sec.vbs /sc minute /mo 100 /st 17:00 /et 08:00 /k
To schedule a task that runs every N hours
Hourly Schedule Syntax
Remarks
Examples
To schedule a task that runs every five hours
Because the local computer is set to use the English (Zimbabwe) option in Regional and Language Options, the format for the start date is MM/DD/YYYY (03/01/2002).
schtasks /create /sc hourly /mo 5 /sd 03/01/2002 /tn "My App" /tr c:\apps\myapp.exe
To schedule a task that runs every hour at five minutes past the hour
schtasks /create /sc hourly /st 00:05 /tn "My App" /tr c:\apps\myapp.exe
To schedule a task that runs every 3 hours for 10 hours
The command uses the /sc parameter to specify an hourly schedule and the /mo parameter to specify the interval of 3 hours. It uses the /st parameter to start the schedule at midnight and the /du parameter to end the recurrences after 10 hours. Because the program runs for just a few minutes, the /k parameter, which stops the program if it is still running when the duration expires, is not necessary.
schtasks /create /tn "My App" /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 is not run again at 12:00 P.M. Instead, it starts again at 12:00 A.M. the next day.
To schedule a task that runs every N days
Daily Schedule Syntax
Remarks
Examples
To schedule a task that runs every day
In this example, because the local computer system is set to the English (United Kingdom) option in Regional and Language Options in Control Panel, the format for the end date is DD/MM/YYYY (31/12/2002)
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc daily /st 08:00 /ed 31/12/2002
To schedule a task that runs every 12 days
In this example, because the system is set to the English (Zimbabwe) option in Regional and Language Options in Control Panel, the format for the end date is MM/DD/YYYY (12/31/2002)
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc daily /mo 12 /sd 12/31/2002 /st 13:00
To schedule a task that runs every 70 days if I am logged on
schtasks /create /tn "Security Script" /tr sec.vbs /sc daily /mo 70 /it
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 that runs every N weeks
Weekly Schedule Syntax
Remarks
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 a task that runs every six weeks
This command 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. Because the /p parameter is omitted, SchTasks.exe prompts the user for the Administrator account password.
Also, because the command is run remotely, all paths in the command, including the path to MyApp.exe, refer to paths on the remote computer.
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc weekly /mo 6 /s Server16 /u Admin01
To schedule a task that runs every other week on Friday
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc weekly /mo 2 /d FRI
To schedule a task that runs every N months
Syntax
Remarks
Examples
To schedule a task that runs on the first day of every month
schtasks /create /tn "My App" /tr myapp.exe /sc monthly
To schedule a task that runs every three months
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo 3
To schedule a task that runs at midnight on the 21st day of every other month
The command uses the /mo parameter to specify the monthly interval (every two months), the /d parameter to specify the date, and the /st to specify the time. It also uses the /sd and /ed parameters to specify the start date and end date, respectively. Because the local computer is set to the English (South Africa) option in Regional and Language Options in the Control Panel, the dates are specified in the local format, which is YYYY/MM/DD.
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo 2 /d 21 /st 00:00 /sd 2002/07/01 /ed 2003/06/30
To schedule a task that runs on a specific day of the week
Weekly Schedule Syntax
Remarks
Examples
To schedule a task that runs every Wednesday
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc weekly /d WED
To schedule a task that runs every eight weeks on Monday and Friday
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc weekly /mo 8 /d MON,FRI
To schedule a task that runs on a specific week of the month
Specific Week Syntax
Remarks
Examples
To schedule a task for the second Sunday of every month
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo SECOND /d SUN
To schedule a task for the first Monday in March and September
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo FIRST /d MON /m MAR,SEP
To schedule a task that runs on a specific date each month
Specific date syntax
Remarks
The /m (month) parameter is optional for this schedule type and the default is every month (*). Schtasks does not let you schedule a task for a date that does not occur in a month specified by the /m parameter. However, if omit the /m parameter, and schedule a task for a date that does not appear in every month, such as the 31st day, then the task does not 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 a task for the first day of every month
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly
To schedule a task for the 15th days of May and June
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /d 15 /m MAY,JUN /st 15:00
To schedule a task that runs on a the last day of a month
Last day syntax
Remarks
Examples
To schedule a task for the last day of every month
The following command schedules the MyApp program to run on the last day of every month that contains 31 days.
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo lastday /m JAN,MAR,MAY,JUL,AUG,OCT,DEC
The following command schedules the MyApp program to run on the last day of every month that contains 30 days.
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo lastday /m APR,JUN,SEP,NOV
The following command schedules the MyApp program to run on the last day of February.
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo lastday /m FEB
To schedule a task at 6:00 P.M. on the last day of February
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo lastday /m FEB /st 18:00
To schedule a task that runs once
Syntax
Remarks
Schtasks does not permit you to schedule a task to run once if the date and time specified are in the past, based on the time of the local computer. To schedule a task that runs once on a remote computer in a different time zone, you must schedule it before that date and time occurs on the local computer.
Examples
To schedule a task that runs one time
Because the local computer is uses the English (United States) option in Regional and Language Options in Control Panel, the format for the start date is MM/DD/YYYY.
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc once /sd 01/01/2003 /st 00:00
To schedule a task that runs every time the system starts
Syntax
Remarks
Examples
To schedule a task that runs when the system starts
Because the local computer is uses the English (United States) option in Regional and Language Options in Control Panel, the format for the start date is MM/DD/YYYY.
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc onstart /sd 03/15/2001
To schedule a task that runs when a user logs on
Syntax
Remarks
Examples
To schedule a task that runs when a user logs on to a remote computer
schtasks /create /tn "Start Web Site" /tr c:\myiis\webstart.bat /sc onlogon /s Server23
To schedule a task that runs when the system is idle
Syntax
Remarks
Examples
To schedule a task that runs whenever the computer is idle
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc onidle /i 10
To schedule a task that runs now
Syntax
Examples
To schedule a task that runs a few minutes from now.
Because the local computer is uses the English (United States) option in Regional and Language Options in Control Panel, the format for the start date is MM/DD/YYYY.
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc once /st 14:18 /sd 11/13/2002
To schedule a task that runs with different permissions
Examples
To run a task with Administrator permissions on the local computer
schtasks /create /tn "My App" /tr myapp.exe /sc weekly /d TUE /ru Admin06
In response, SchTasks.exe prompts for the "run as" password for the Admin06 account and then displays a success message.
Please enter the run as password for Admin06: ******** SUCCESS: The scheduled task "My App"
has successfully been created.
To run a task with alternate permissions on a remote computer
The command uses the /sc parameter to specify a daily schedule and /mo parameter to specify an interval of four days.
The command uses the /s parameter to provide the name of the remote computer and the /u parameter to specify an account with permission to schedule a task on the remote computer (Admin01 on the Marketing computer). It also uses the /ru parameter to specify that the task should run with the permissions of the user's non-Administrator account (User01 in the Reskits domain). Without the /ru parameter, the task would run with the permissions of the account specified by /u.
schtasks /create /tn "My App" /tr myapp.exe /sc daily /mo 4 /s Marketing /u Marketing\Admin01 /ru Reskits\User01
Schtasks first requests the password of the user named by the /u parameter (to run the command) and then requests the password of the user named by the /ru parameter (to run the task). After authenticating the passwords, Schtasks displays a message indicating that the task is scheduled.
Type the password for Marketing\Admin01:
******** Please enter the run as password for
Reskits\User01: ******** SUCCESS: The scheduled task "My App"
has successfully been created.
To run a task only when a particular user is logged on
The command uses the /sc parameter to specify a weekly schedule, the /d parameter to specify the day, and the /st parameter to specify the start time.
The command uses the /s parameter to provide the name of the remote computer and the /u parameter to specify an account with permission to schedule a task on the remote computer. It also uses the /ru parameter to configure the task to run with the permissions of the administrator of the Public computer (Public\Admin01) and the /it parameter to indicate that the task runs only when the Public\Admin01 account is logged on.
schtasks /create /tn "Check Admin" /tr AdminCheck.exe /sc weekly /d FRI /st 04:00 /s Public /u Domain3\Admin06 /ru Public\Admin01 /it
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 that runs with system permissions
Important
- The System account does not have interactive logon rights. Users cannot see or interact with programs or tasks run with system permissions.
- The /ru parameter determines the permissions under which the task runs, not the permissions used to schedule the task. Only Administrators can schedule tasks, regardless of the value of the /ru parameter.
Note
- To identify tasks that run with system permissions, use a verbose query (/query /v). In a verbose query display of a system-run task, the Run As User field has a value of NT AUTHORITY\SYSTEM and the Logon Mode field has a value of Background only.
Examples
To run a task with system permissions
The command uses the /ru System parameter to specify the system security context. Because system tasks do not use a password, the /rp parameter is omitted.
schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /d 15 /ru System
In response, SchTasks.exe displays an informational message and a success message. It does not prompt for a password.
INFO: The task will be created under user
name ("NT AUTHORITY\SYSTEM"). SUCCESS: The Scheduled task "My App" has
successfully been created.
To run a task with system permissions on a remote computer
The command uses the /tn parameter to name the task and the /tr parameter to specify the remote copy of the MyApp program. It uses the /sc parameter to specify a daily schedule, but omits the /mo parameter because 1 (every day) is the default. It uses the /st parameter to specify the start time, which is also the time the task will run each day.
The command uses the /s parameter to provide the name of the remote computer and the /u parameter to specify an account with permission to schedule a task on the remote computer. It also uses the /ru parameter to specify that the task should run under the System account. Without the /ru parameter, the task would run with the permissions of the account specified by /u.
schtasks /create /tn "My App" /tr myapp.exe /sc daily /st 04:00 /s Finance01 /u Admin01 /ru System
Schtasks requests the password of the user named by the /u parameter and, after authenticating the password, displays a message indicating that the task is created and that it will run with permissions of the system account.
Type the password for Admin01:********** INFO: The Schedule Task "My App" will be
created under user name ("NT AUTHORITY\ SYSTEM"). SUCCESS: The scheduled task "My App" has
successfully been created.
To schedule a task that runs more than one program
- Create a batch file that starts the programs you want to
run.
In this example, you create a batch file that starts Event Viewer (Eventvwr.exe) and System Monitor (Perfmon.exe).
- Open a text editor, such as Notepad.
- Type the name and fully qualified path to the
executable file for each program. In this case, the file
includes the following statements.
C:\Windows\System32\Eventvwr.exe C:\Windows\System32\Perfmon.exe
- Save the file as MyApps.bat.
- Use SchTasks.exe to create a task that runs MyApps.bat.
The following command creates the Monitor task, which runs whenever anyone logs on. It uses the /tn parameter to name the task, and the /tr parameter to run MyApps.bat. It uses the /sc parameter to indicate the OnLogon schedule type and the /ru parameter to run the task with the permissions of the user's Administrator account.
schtasks /create /tn Monitor /tr C:\MyApps.bat /sc onlogon /ru Reskit\Administrator
As a result of this command, whenever a user logs on to the computer, the task starts both Event Viewer and System Monitor.
To schedule a task that runs on a remote computer
- You must have permission to schedule the task. As such, you must be logged on to the local computer with an account that is a member of the Administrators group on the remote computer, or you must use the /u parameter to provide the credentials of an Administrator of the remote computer.
- You can use the /u parameter only when the local and remote computers are in the same domain or the local computer is in a domain that the remote computer domain trusts. Otherwise, the remote computer cannot authenticate the user account specified and it cannot verify that the account is a member of the Administrators group.
- The task must have sufficient permission to run on the remote computer. The permissions required vary with the task. By default, the task runs with the permission of the current user of the local computer or, if the /u parameter is used, the task runs with the permission of the account specified by the /u parameter. However, you can use the /ru parameter to run the task with permissions of a different user account or with system permissions.
Examples
An Administrator schedules a task on a remote computer
Please note that when scheduling tasks on a remote computer, all parameters refer to the remote computer. Therefore, the executable file specified by the /tr parameter refers to the copy of MyApp.exe on the remote computer.
schtasks /create /s SRV01 /tn "My App" /tr "c:\program files\corpapps\myapp.exe" /sc daily /mo 10
In response, Schtasks displays a success message indicating that the task is scheduled.
A user schedules a command on a remote computer (Case 1)
schtasks /create /s SRV06 /tn "My App" /tr "c:\program files\corpapps\myapp.exe" /sc hourly /mo 3 /u reskits\admin01 /p R43253@4$ /ru SRV06\user03 /rp MyFav!!Pswd
In response, Schtasks displays a success message indicating that the task is scheduled.
A user schedules a command on a remote computer (Case 2)
schtasks /create /s SRV02 /tn "My App" /tr "c:\program files\corpapps\myapp.exe" /sc monthly /mo LASTDAY /m * /u reskits\admin01
Because the command did not include the /p (password) parameter, Schtasks prompts for the password. Then it displays a success message and, in this case, a warning.
Type the password for reskits\admin01:
******** SUCCESS: The scheduled task "My App" has
successfully been created. WARNING: The Scheduled task "My App" has
been created, but may not run because the account information could not be set.
This warning indicates that the remote domain could not authenticate the account specified by the /u parameter. In this case, the remote domain could not authenticate the user account because the local computer is not a member of a domain that the remote computer domain trusts. When this occurs, the task job appears in the list of scheduled tasks, but the task is actually empty and it will not run.
The following display from a verbose query exposes the problem with the task. In the display, note that the value of Next Run Time is Never and that the value of Run As User is Could not be retrieved from the task scheduler database.
Had this computer been a member of the same domain or a trusted domain, the task would have been successfully scheduled and would have run as specified.
HostName: SRV44 TaskName: My App Next Run Time: Never Status: Logon mode: Interactive/Background Last Run Time: Never Last Result: 0 Creator: user03 Schedule: At 3:52 PM on day 31 of every month, start starting 12/14/2001 Task To Run: c:\program files\corpapps\myapp.exe Start In: myapp.exe Comment: N/A Scheduled Task State: Disabled Scheduled Type: Monthly Start Time: 3:52:00 PM Start Date: 12/14/2001 End Date: N/A Days: 31 Months: JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NO V,DEC Run As User: Could not be retrieved from the task sched uler database Delete Task If Not Rescheduled: Enabled Stop Task If Runs X Hours and X Mins: 72:0 Repeat: Every: Disabled Repeat: Until: Time: Disabled Repeat: Until: Duration: Disabled Repeat: Stop If Still Running: Disabled Idle Time: Disabled Power Management: Disabled
Remarks
- To run a /create command with the permissions of a different user, use the /u parameter. The /u parameter is valid only for scheduling tasks on remote computers.
- To view more schtasks /create examples, type schtasks /create /? at a command prompt.
- To schedule a task that runs with permissions of a different user, use the /ru parameter. The /ru parameter is valid for tasks on local and remote computers.
- To use the /u parameter, the local computer must be in the same domain as the remote computer or must be in a domain that the remote computer domain trusts. Otherwise, either the task is not created, or the task job is empty and the task does not run.
- Schtasks always prompts for a password unless you provide one, even when you schedule a task on the local computer using the current user account. This is normal behavior for Schtasks.
- Schtasks does not verify program file locations or user account passwords. If you do not enter the correct file location or the correct password for the user account, the task is created, but it does not run. Also, if the password for an account changes or expires, and you do not change the password saved in the task, then the task does not run.
- The System account does not have interactive logon rights. Users do not see and cannot interact with programs run with system permissions.
- Each task runs only one program. However, you can create a batch file that starts multiple tasks, and then schedule a task that runs the batch file.
- You can test a task as soon as you create it. Use the run operation to test the task and then check the SchedLgU.txt file (Systemroot\SchedLgU.txt) for errors.
schtasks change
- The program that the task runs (/tr).
- The user account under which the task runs (/ru).
- The password for the user account (/rp).
- Adds the interactive-only property to the task (/it).
Syntax
Parameters
Remarks
- The /tn and /s parameters identify the task. The /tr, /ru, and /rp parameters specify properties of the task that you can change.
- The /ru and /rp parameters specify the permissions under which the task runs. The /u and /p parameters specify the permissions used to change the task.
- To change tasks on a remote computer, the user must be logged on to the local computer with an account that is a member of the Administrators group on the remote computer.
- To run a /change command with the permissions of a different user (/u, /p), the local computer must be in the same domain as the remote computer or must be in a domain that the remote computer domain trusts.
- The System account does not have interactive logon rights. Users do not see and cannot interact with programs run with system permissions.
- To identify tasks with the /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.
Examples
To change the program that a task runs
schtasks /change /tn "Virus Check" /tr C:\VirusCheck2.exe
In response, SchTasks.exe displays the following success message:
SUCCESS: The parameters of the scheduled task "Virus Check" have been changed.
As a result of this command, the Virus Check task now runs VirusCheck2.exe.
To change the password for a remote task
This procedure is required whenever the password for a user account expires or changes. If the password saved in a task is no longer valid, then the task does not run.
schtasks /change /tn RemindMe /s Svr01 /rp p@ssWord3
In response, SchTasks.exe displays the following success message:
SUCCESS: The parameters of the scheduled task "RemindMe" have been changed.
As a result of this command, the RemindMe task now runs under its original user account, but with a new password.
To change the program and user account for a task
The command uses the /tn parameter to identify the task. It uses the /tr parameter to change the program that the task runs and the /ru parameter to change the user account under which the task runs.
The /rp parameter, which provides the password for the user account, is omitted. You must provide a password for the account, but you can use the /rp parameter and type the password in clear text, or wait for SchTasks.exe to prompt you for a password, and then enter the password in obscured text.
schtasks /change /tn ChkNews /tr "c:\program files\Internet Explorer\iexplore.exe" /ru DomainX\Admin01
In response, SchTasks.exe requests the password for the user account. It obscures the text you type, so the password is not visible.
Please enter the password for DomainX\Admin01:
Note that the /tn parameter identifies the task and that the /tr and /ru parameters change the properties of the task. You cannot use another parameter to identify the task and you cannot change the task name.
In response, SchTasks.exe displays the following success message:
SUCCESS: The parameters of the scheduled task "ChkNews" have been changed.
As a result of this command, the ChkNews task now runs Internet Explorer with the permissions of an Administrator account.
To change a program to the System account
schtasks /change /tn SecurityScript /ru ""
In response, SchTasks.exe displays the following success message:
INFO: The run as user name for the scheduled task "SecurityScript" will be changed to "NT AUTHORITY\SYSTEM". SUCCESS: The parameters of the scheduled task "SecurityScript" have been changed.
Because tasks run with System account permissions do not require a password, SchTasks.exe does not prompt for one.
To run a program only when I am logged on
The command uses the /tn parameter to identify the task and the /it parameter to add the interactive-only property to the task. Because the task already runs with the permissions of my user account, I do not need to change the /ru parameter for the task.
schtasks /change /tn MyApp /it
In response, SchTasks.exe displays the following success message.
SUCCESS: The parameters of the scheduled task "MyApp" have been changed.
schtasks run
Syntax
Parameters
Remarks
- Use this operation to test your tasks. If a task does not run, check the Task Scheduler Service transaction log, Systemroot\SchedLgU.txt, for errors.
- Running a task does not affect the task schedule and does not change the next run time scheduled for the task.
- To run a task remotely, the task must be scheduled on the remote computer. When you run it, the task runs only on the remote computer. To verify that a task is running on a remote computer, use Task Manager or the Task Scheduler transaction log, Systemroot\SchedLgU.txt.
Examples
To run a task on the local computer
schtasks /run /tn "Security Script"
In response, SchTasks.exe starts the script associated with the task and displays the following message:
SUCCESS: Attempted to run the scheduled task "Security Script".
As the message implies, Schtasks tries to start the program, but it cannot very that the program actually started.
To run a task on a remote computer
schtasks /run /tn Update /s Svr01
In this case, SchTasks.exe displays the following error message:
ERROR: Unable to run the scheduled task "Update".
To find the cause of the error, look in the Scheduled Tasks transaction log, C:\Windows\SchedLgU.txt on Svr01. In this case, the following entry appears in the log:
"Update.job" (update.exe) 3/26/2001 1:15:46 PM ** ERROR ** The attempt to log on to the account associated with the task failed, therefore, the task did not run. The specific error is: 0x8007052e: Logon failure: unknown user name or bad password. Verify that the task's Run-as name and password are valid and try again.
Apparently, the user name or password in the task is not valid on the system. The following schtasks /change command updates the user name and password for the Update task on Svr01:
schtasks /change /tn Update /s Svr01 /ru Administrator /rp PassW@rd3
After the change command completes, the run command is repeated. This time, the Update.exe program starts and SchTasks.exe displays the following message:
SUCCESS: Attempted to run the scheduled task "Update".
As the message implies, Schtasks tries to start the program, but it cannot very that the program actually started.
schtasks end
Syntax
Parameters
Remarks
- SchTasks.exe ends only the instances of a program started by a scheduled task. To stop other processes, use TaskKill, a tool included in Windows XP Professional. For more information about TaskKill, see Taskkill
Examples
To end a task on a local computer
schtasks /end /tn "My Notepad"
In response, SchTasks.exe stops the instance of Notepad.exe that the task started, and it displays the following success message:
SUCCESS: The scheduled task "My Notepad" has been terminated successfully.
To end a task on a remote computer
schtasks /end /tn InternetOn /s Svr01
In response, SchTasks.exe stops the instance of Internet Explorer that the task started, and it displays the following success message:
SUCCESS: The scheduled task "InternetOn" has been terminated successfully.
schtasks delete
Syntax
Parameters
Remarks
- The delete operation deletes the task from the schedule. It does not delete the program that the task runs or interrupt a running program.
- The delete * command deletes all tasks scheduled for the computer, not just the tasks scheduled by the current user.
Examples
To delete a task from the schedule of a remote computer
schtasks /delete /tn "Start Mail" /s Svr16
In response, SchTasks.exe displays the following confirmation message. To delete the task, type y. To cancel the command, type n:
WARNING: Are you sure you want to remove the task "Start Mail" (Y/N )? SUCCESS: The scheduled task "Start Mail" was successfully deleted.
To delete all tasks scheduled for the local computer
schtasks /delete /tn * /f
In response, SchTasks.exe displays the following success messages indicating that the only task scheduled, SecureScript, is deleted.
SUCCESS: The scheduled task "SecureScript" was successfully deleted.
schtasks query
Syntax
Parameters
Remarks
- The query operation lists all tasks that the user has permission to view. Administrators can view all tasks on the computer. Users can view only the tasks that they scheduled.
Examples
To display the scheduled tasks on the local computer
schtasks
schtasks /query
In response, SchTasks.exe displays the tasks in the default, simple table format, as shown in the following table:
TaskName Next Run Time Status ========================= ======================== ============== Microsoft Outlook At logon time SecureScript 14:42:00 PM , 2/4/2001
To display advanced properties of scheduled tasks
schtasks /query /fo LIST /v
In response, SchTasks.exe displays a detailed property list for all tasks. The following display shows the task list for a task scheduled to run at 4:00 A.M. on the last Friday of every month:
HostName: RESKIT01 TaskName: SecureScript Next Run Time: 4:00:00 AM , 3/30/2001 Status: Not yet run Logon mode: Interactive/Background Last Run Time: Never Last Result: 0 Creator: user01 Schedule: At 4:00 AM on the last Fri of every month, starting 3/24/2001 Task To Run: C:\WINDOWS\system32\notepad.exe Start In: notepad.exe Comment: N/A Scheduled Task State: Enabled Scheduled Type: Monthly Modifier: Last FRIDAY Start Time: 4:00:00 AM Start Date: 3/24/2001 End Date: N/A Days: FRIDAY Months: JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC Run As User: RESKIT\user01 Delete Task If Not Rescheduled: Enabled Stop Task If Runs X Hours and X Mins: 72:0 Repeat: Until Time: Disabled Repeat: Duration: Disabled Repeat: Stop If Still Running: Disabled Idle: Start Time(For IDLE Scheduled Type): Disabled Idle: Only Start If Idle for X Minutes: Disabled Idle: If Not Idle Retry For X Minutes: Disabled Idle: Stop Task If Idle State End: Disabled Power Mgmt: No Start On Batteries: Disabled Power Mgmt: Stop On Battery Mode: Disabled
To log tasks scheduled for a remote computer
The command uses the /s parameter to identify the remote computer, Reskit16, the /fo parameter to specify the format and the /nh parameter to suppress the column headings. The >> append symbol redirects the output to the task log, p0102.csv, on the local computer, Svr01. Because the command runs on the remote computer, the local computer path must be fully qualified.
schtasks /query /s Reskit16 /fo csv /nh >> \\svr01\data\tasklogs\p0102.csv
In response, SchTasks.exe adds the tasks scheduled for the Reskit16 computer to the p0102.csv file on the local computer, Svr01.
Remarks
- This help file describes the version of Schtasks.exe included in the Windows Server™ 2003 family. For information about the version of Schtasks.exe in Windows XP Professional, see the Schtasks topic in Windows XP Professional Help.
- SchTasks.exe performs the same operations as Scheduled Tasks in Control Panel. You can use these tools together and interchangeably.
- Schtasks replaces At.exe, a tool included in previous versions of Windows. Although At.exe is still included in the Windows Server™ 2003 family, Schtasks is the recommended command-line task scheduling tool.
- The parameters in a Schtasks command can appear in any order. Typing schtasks without any parameters performs a query.
- Permissions for Schtasks
- You must have permission to run the command. Any user can schedule a task on the local computer, and they can view and change the tasks that they scheduled. Members of the Administrators group can schedule, view, and change all tasks on the local computer.
- To schedule, view, or change a task on a remote computer, you must be member of the Administrators group on the remote computer, or you must use the /u parameter to provide the credentials of an Administrator of the remote computer.
- You can use the /u parameter in a /create or /change operation only when the local and remote computers are in the same domain or the local computer is in a domain that the remote computer domain trusts. Otherwise, the remote computer cannot authenticate the user account specified and it cannot verify that the account is a member of the Administrators group.
- The task must have permission to run. The permissions required vary with the task. By default, tasks run with the permissions of the current user of the local computer, or with the permissions of the user specified by the /u parameter, if one is included. To run a task with permissions of a different user account or with system permissions, use the /ru parameter.
- To verify that a scheduled task ran or to find out why a scheduled task did not run, see the Task Scheduler service transaction log, Systemroot\SchedLgU.txt. This log records attempted runs initiated by all tools that use the service, including Scheduled Tasks and SchTasks.exe.
- On rare occasions, task files become corrupted. Corrupted
tasks do not run. When you try to perform an operation on
corrupted tasks, SchTasks.exe displays the following error
message:
ERROR: The data is invalid.
You cannot recover corrupted tasks. To restore the task scheduling features of the system, use SchTasks.exe or Scheduled Tasks to delete the tasks from the system and reschedule them.
Formatting legend
Format | Meaning |
Italic | Information that the user must supply |
Bold | Elements that the user must type exactly as shown |
Ellipsis (...) | Parameter that can be repeated several times in a command line |
Between brackets ([]) | Optional items |
Between braces ({}); choices separated by pipe (|). Example: {even|odd} | Set of choices from which the user must choose only one |
Courier font | Code or program output |