Advertisement
Najeebsk

SCHEDUL-TASK.txt

Dec 5th, 2022
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 92.21 KB | None | 0 0
  1. SCHTASKS /Create /SC MINUTE /MO 5 /TN BackUp /TR "C:\Windows\notepad.exe"
  2. -----------------------------------------------------------------------
  3. SchTasks /Create /SC MINUTE /MO 5 /SD 12/31/9999 /TN "My Task" /TR %~dp0%~n0%~x0 /ST 23:59:59
  4. -----------------------------------------------------------------------
  5. SCHTASKS /CREATE /SC DAILY /TN "FOLDERPATH\TASKNAME" /TR "C:\SOURCE\FOLDER\APP-OR-SCRIPT" /ST HH:MMExampleSCHTASKS /CREATE /SC DAILY /TN "MyTasks\Notepad task" /TR "C:\Windows\System32\notepad.exe" /ST 11:00
  6. -----------------------------------------------------------------------
  7. schtasks /create /sc minute /mo 5 /tn "TaskName" /tr \\scripts\whatever.bat
  8. -=-=-=-=-=-=-=-=-=-=-=-=-START-=-=-=-=-=-=-=-=-=-=-=-=-
  9. To schedule the MyApp program to run once a day, every day, at 8:00 A.M. until December 31, 2021, type:
  10. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc daily /st 08:00 /ed 31/12/2021
  11. -----------------------------------------------------------------------
  12. To schedule a security script, Sec.vbs, to run every 20 minutes, type:
  13. schtasks /create /sc minute /mo 20 /tn "Security Script" /tr \\central\data\scripts\sec.vbs
  14. -----------------------------------------------------------------------
  15. 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:
  16. schtasks /create /tn "Security Script" /tr sec.vbs /sc minute /mo 100 /st 17:00 /et 08:00 /k
  17. -----------------------------------------------------------------------
  18. To schedule the MyApp program to run every five hours, beginning on the first day of March 2002, type:
  19. schtasks /create /sc hourly /mo 5 /sd 03/01/2002 /tn My App /tr c:\apps\myapp.exe
  20. ------------------------------------------------------------------------------
  21. To schedule the MyApp program to run hourly, beginning at five minutes past midnight, type:
  22. schtasks /create /sc hourly /st 00:05 /tn MyApp /tr c:\apps\myapp.exe
  23. ------------------------------------------------------------------------------
  24. To schedule the MyApp program to run every 3 hours, for 10 hours total, type:
  25. schtasks /create /tn MyApp /tr myapp.exe /sc hourly /mo 3 /st 00:00 /du 0010:00
  26. ------------------------------------------------------------------------------
  27. To schedule the MyApp program to run every twelve days at 1:00 P.M. (13:00) beginning on December 31, 2021, type:
  28. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc daily /mo 12 /sd 12/31/2002 /st 13:00
  29. ---------------------------------------------------------------------------------
  30. To schedule a security script, Sec.vbs, to run every 70 days, type:
  31. schtasks /create /tn "Security Script" /tr sec.vbs /sc daily /mo 70 /it
  32. ---------------------------------------------------------------------------------
  33. To schedule the MyApp program to run on a remote computer every six weeks, type:
  34. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc weekly /mo 6 /s Server16 /u Admin01
  35. ---------------------------------------------------------------------------------
  36. To schedule a task to run every other Friday, type:
  37. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc weekly /mo 2 /d FRI
  38. ---------------------------------------------------------------------------------
  39. To schedule the MyApp program to run on the first day of every month, type:
  40. schtasks /create /tn MyApp /tr myapp.exe /sc monthly
  41. -----------------------------------------------------------------------------------
  42. To schedule the MyApp program to run every three months, type:
  43. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /mo 3
  44. -----------------------------------------------------------------------------------
  45. 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:
  46. 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
  47. ----------------------------------------------------------------------------------
  48. To schedule the MyApp program to run every week on Wednesday, type:
  49. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc weekly /d WED
  50. ----------------------------------------------------------------------------------
  51. To schedule a task to run on Monday and Friday of every eighth week, type:
  52. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc weekly /mo 8 /d MON,FRI
  53. ----------------------------------------------------------------------------------
  54. To schedule the MyApp program to run on the second Sunday of every month, type:
  55. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /mo SECOND /d SUN
  56. ----------------------------------------------------------------------------------
  57. To schedule the MyApp program to run on the first Monday in March and September, type:
  58. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /mo FIRST /d MON /m MAR,SEP
  59. ----------------------------------------------------------------------------------
  60. To schedule the MyApp program to run on the first day of every month, type:
  61. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly
  62. ----------------------------------------------------------------------------------
  63. To schedule the MyApp program to run on May 15 and June 15 at 3:00 P.M. (15:00), type:
  64. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /d 15 /m MAY,JUN /st 15:00
  65. ----------------------------------------------------------------------------------
  66. To schedule the MyApp program to run on the last day of every month, type:
  67. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /mo lastday /m *
  68. ----------------------------------------------------------------------------------
  69. 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:
  70. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /mo lastday /m FEB,MAR /st 18:00
  71. ----------------------------------------------------------------------------------
  72. To schedule the MyApp program to run at midnight on January 1, 2003, type:
  73. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc once /sd 01/01/2003 /st 00:00
  74. ----------------------------------------------------------------------------------
  75. To schedule the MyApp program to run every time the system starts, type:
  76. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc onstart
  77. ----------------------------------------------------------------------------------
  78. To schedule a task that runs when a user logs on to a remote computer, type:
  79. schtasks /create /tn "Start Web Site" /tr c:\myiis\webstart.bat /sc onlogon /s Server23
  80. ----------------------------------------------------------------------------------
  81. To schedule the MyApp program to run whenever the computer is idle, type:
  82. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc onidle /i 10
  83. ----------------------------------------------------------------------------------
  84. To schedule a task to run once, on November 13, 2020 at 2:18 P.M. local time, type:
  85. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc once /st 14:18 /sd 11/13/2002
  86. ----------------------------------------------------------------------------------
  87. To run the MyApp program on the local computer, type:
  88. schtasks /create /tn MyApp /tr myapp.exe /sc weekly /d TUE /ru Admin06
  89. ----------------------------------------------------------------------------------
  90. To run the MyApp program on the Marketing computer every four days, type:
  91. schtasks /create /tn MyApp /tr myapp.exe /sc daily /mo 4 /s Marketing /u Marketing\Admin01 /ru Reskits\User01
  92. ----------------------------------------------------------------------------------
  93. To run schedule the AdminCheck.exe program to run on the Public computer every Friday at 4:00 A.M.,, but only if the administrator of the computer is logged on, type:
  94. schtasks /create /tn "Check Admin" /tr AdminCheck.exe /sc weekly /d FRI /st 04:00 /s Public /u Domain3\Admin06 /ru Public\Admin01 /it
  95. ----------------------------------------------------------------------------------
  96. To schedule the MyApp program to run on the local computer with permissions of the System account, type:
  97. schtasks /create /tn MyApp /tr c:\apps\myapp.exe /sc monthly /d 15 /ru System
  98. ----------------------------------------------------------------------------------
  99. To schedule the MyApp program to run on the Finance01 computer every morning at 4:00 A.M., using system permissions, type:
  100. schtasks /create /tn MyApp /tr myapp.exe /sc daily /st 04:00 /s Finance01 /u Admin01 /ru System
  101. ----------------------------------------------------------------------------------
  102. Each task runs only one program. However, you can create a batch file that runs multiple programs and then schedule a task to run the batch file.
  103.  
  104. Using a text editor, such as Notepad, create a batch file that includes the name and fully qualified path to the .exe file required to start the Event Viewer (Eventvwr.exe) and System Monitor (Perfmon.exe) programs.
  105.  
  106. C:\Windows\System32\Eventvwr.exe
  107. C:\Windows\System32\Perfmon.exe
  108.  
  109. Save the file as MyApps.bat, open schtasks.exe, and then create a task to run MyApps.bat by typing:
  110. schtasks /create /tn Monitor /tr C:\MyApps.bat /sc onlogon /ru Reskit\Administrator
  111. ----------------------------------------------------------------------------------
  112. To schedule the MyApp program (as an administrator) to run on the SRV01 remote computer every ten days starting immediately,type:
  113. schtasks /create /s SRV01 /tn MyApp /tr c:\program files\corpapps\myapp.exe /sc daily /mo 10
  114. ----------------------------------------------------------------------------------
  115. To schedule the MyApp program (as a user) to run on the SRV06 remote computer every three hours, type:
  116. schtasks /create /s SRV06 /tn MyApp /tr c:\program files\corpapps\myapp.exe /sc hourly /mo 3 /u reskits\admin01 /p R43253@4$ /ru SRV06\user03 /rp MyFav!!Pswd
  117. ----------------------------------------------------------------------------------
  118. To schedule the MyApp program (as a user) to run on the SRV02 remote computer on the last day of every month.
  119. schtasks /create /s SRV02 /tn MyApp /tr c:\program files\corpapps\myapp.exe /sc monthly /mo LASTDAY /m * /u reskits\admin01
  120. ----------------------------------------------------------------------------------
  121. 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.
  122.  
  123. 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.
  124.  
  125. HostName: SRV44
  126. TaskName: MyApp
  127. Next Run Time: Never
  128. Status:
  129. Logon mode: Interactive/Background
  130. Last Run Time: Never
  131. Last Result: 0
  132. Creator: user03
  133. Schedule: At 3:52 PM on day 31 of every month, start
  134. starting 12/14/2001
  135. Task To Run: c:\program files\corpapps\myapp.exe
  136. Start In: myapp.exe
  137. Comment: N/A
  138. Scheduled Task State: Disabled
  139. Scheduled Type: Monthly
  140. Start Time: 3:52:00 PM
  141. Start Date: 12/14/2001
  142. End Date: N/A
  143. Days: 31
  144. Months: JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NO
  145. V,DEC
  146. Run As User: Could not be retrieved from the task sched
  147. uler database
  148. Delete Task If Not Rescheduled: Enabled
  149. Stop Task If Runs X Hours and X Mins: 72:0
  150. Repeat: Every: Disabled
  151. Repeat: Until: Time: Disabled
  152. Repeat: Until: Duration: Disabled
  153. Repeat: Stop If Still Running: Disabled
  154. Idle Time: Disabled
  155. Power Management: Disabled
  156. -=-=-=-=-=-=-=-=-=-=-=-=-END-=-=-=-=-=-=-=-=-=-=-=-=-
  157. schtasks create
  158. 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.
  159.  
  160. Combined syntax and parameter descriptions
  161.  
  162. To schedule a task that runs every N minutes
  163.  
  164. To schedule a task that runs every N hours
  165.  
  166. To schedule a task that runs every N days
  167.  
  168. To schedule a task that runs every N weeks
  169.  
  170. To schedule a task that runs every N months
  171.  
  172. To schedule a task that runs on a specific day of the week
  173.  
  174. To schedule a task that runs on a specific week of the month
  175.  
  176. To schedule a task that runs on a specific date each month
  177.  
  178. To schedule a task that runs on a the last day of a month
  179.  
  180. To schedule a task that runs once
  181.  
  182. To schedule a task that runs every time the system starts
  183.  
  184. To schedule a task that runs when a user logs on
  185.  
  186. To schedule a task that runs when the system is idle
  187.  
  188. To schedule a task that runs now
  189.  
  190. To schedule a task that runs with different permissions
  191.  
  192. To schedule a task that runs with system permissions
  193.  
  194. To schedule a task that runs more than one program
  195.  
  196. To schedule a task that runs on a remote computer
  197.  
  198. Combined syntax and parameter descriptions
  199. Syntax
  200.  
  201. 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] [/Z] [/F]
  202. Parameters
  203.  
  204. /sc ScheduleType
  205. Specifies the schedule type. Valid values are MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE.
  206. /tn TaskName
  207. Specifies a name for the task. Each task on the system must have a unique name. The name must conform to the rules for file names and must not exceed 238 characters. Use quotation marks to enclose names that include spaces.
  208.  
  209. /tr TaskRun
  210. 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 omit the path, Schtasks assumes that the file is in the Systemroot\System32 directory.
  211.  
  212. /s Computer
  213. Schedules a task on the specified remote computer. Type the name or IP address of a remote computer (with or without backslashes). The default is the local computer. The /u and /p parameters are valid only when you use /s.
  214.  
  215. /u [Domain\]User
  216. 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 for scheduling a task on a remote computer (/s).
  217.  
  218. 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.
  219.  
  220. 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.
  221.  
  222. /p Password
  223. provides the password for the user account specified in the /u parameter. If you use the /u parameter, but omit the /p parameter or the password argument, Schtasks prompts you for a password and obscures the text you type.
  224.  
  225. The **/u** and **/p** parameters are valid only for scheduling a task on a remote computer (**/s**).
  226.  
  227. /ru {[Domain\]User | System}
  228. 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.
  229.  
  230. /rp Password
  231. provides the password for the user account that is specified in the /ru [Domain**\**]User parameter. If you omit this parameter when specifying a user account, SchTasks.exe prompts you for the password and obscures the text you type.
  232.  
  233. Do not use the **/rp** parameter for tasks run with permissions of the System account (**/ru System**). The system account does not have a password and SchTasks.exe does not prompt for one.
  234.  
  235. /mo Modifier
  236. Specifies how often the task runs within its schedule type. This parameter is valid, but optional, for a MINUTE, HOURLY, DAILY, WEEKLY, and MONTHLY schedule. The default value is 1.
  237.  
  238. /d Day[,Day...] | *
  239. Specifies a day (or days) of the week or a day (or days) of a month. Valid only with a WEEKLY or MONTHLY schedule.
  240.  
  241. /m Month[,Month...]
  242. Specifies a month or months of the year during which the scheduled task should run. Valid values are JAN - DEC. The /m parameter is valid only with a MONTHLY schedule. It is required when the LASTDAY modifier is used.
  243.  
  244. /i IdleTime
  245. 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 is required.
  246.  
  247. /st StartTime
  248. Specifies the time of day that the task starts (each time it starts) in HH**:**MM 24-hour format. 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 is required for a ONCE schedule.
  249.  
  250. /ri Interval
  251. Specifies the repetition interval in minutes. This is not applicable for schedule types: MINUTE, HOURLY, ONSTART, ONLOGON, ONIDLE. Valid range is 1 to 599940 minutes (599940 minutes = 9999 hours). If either /ET or /DU is specified, then the repetition interval defaults to 10 minutes.
  252.  
  253. /et EndTime
  254. 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.
  255.  
  256. For an example, see:
  257.  
  258. - "To schedule a task that runs every 100 minutes during non-business hours" in the **To schedule a task that runs every** ***N*** **minutes** section.
  259.  
  260.  
  261. /du Duration
  262. 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.
  263.  
  264. For an example, see:
  265.  
  266. - "To schedule a task that runs every 3 hours for 10 hours" in the **To schedule a task that runs every** ***N*** **hours** section.
  267.  
  268.  
  269. /k
  270. Stops the program that the task runs at the time specified by /et or /du. Without /k, Schtasks does not start the program again after it reaches the time specified by /et or /du, but it does not stop the program if it is still running. This parameter is optional and valid only with a MINUTE or HOURLY schedule.
  271.  
  272. For an example, see:
  273.  
  274. - "To schedule a task that runs every 100 minutes during non-business hours" in the **To schedule a task that runs every** ***N*** **minutes** section.
  275.  
  276.  
  277. /sd StartDate
  278. Specifies the date on which the task schedule starts. The default value is the current date on the local computer. The /sd parameter is valid and optional for all schedule types.
  279.  
  280. The format for the *StartDate* argument varies with the locale selected for the local computer in Regional and Language Options in Control Panel. Only one format is valid for each locale.
  281.  
  282. The valid date formats are listed in the following table. Use the format most similar to the format selected for **Short date** in Regional and Language Options in Control Panel on the local computer.
  283.  
  284. /ed EndDate
  285. Specifies the date on which the schedule ends. This parameter is optional. It is not valid in a ONCE, ONSTART, ONLOGON, or ONIDLE schedule. By default, schedules have no ending date.
  286.  
  287. The format for the *EndDate* argument varies with the locale selected for the local computer in Regional and Language Options in Control Panel. Only one format is valid for each locale.
  288.  
  289. The valid date formats are listed in the following table. Use the format most similar to the format selected for **Short date** in Regional and Language Options in Control Panel on the local computer.
  290.  
  291. /it
  292. Specifies to run the 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.
  293.  
  294. By default, the "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.
  295.  
  296. For examples, see:
  297.  
  298. - "To schedule a task that runs every 70 days if I am logged on" in the **To schedule a task that runs every** ***N*** **days** section.
  299.  
  300. - "To run a task only when a particular user is logged on" in the **To schedule a task that runs with different permissions** section.
  301.  
  302.  
  303. /Z
  304. Specifies to delete the task upon completion of its schedule.
  305.  
  306. /F
  307. Specifies to create the task and suppress warnings if the specified task already exists.
  308.  
  309. /?
  310. Displays help at the command prompt.
  311.  
  312. To schedule a task that runs every N minutes
  313. Minute Schedule Syntax
  314.  
  315. schtasks /create /tn TaskName /tr TaskRun /sc minute [/mo {1 - 1439}] [/st HH**:MM] [/sd** StartDate] [/ed EndDate] [{/et HH**:MM | /du HHHH:MM} [/k**]] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  316. Remarks
  317.  
  318. In a minute schedule, the /sc minute parameter is required. The /mo (modifier) parameter is optional and specifies the number of minutes between each run of the task. The default value for /mo is 1 (every minute). The /et (end time) and /du (duration) parameters are optional and can be used with or without the /k (end task) parameter.
  319. Examples
  320. To schedule a task that runs every 20 minutes
  321.  
  322. The following command schedules a security script, Sec.vbs, to run every 20 minutes. The command uses the /sc parameter to specify a minute schedule and the /mo parameter to specify an interval of 20 minutes.
  323.  
  324. 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.
  325.  
  326. schtasks /create /sc minute /mo 20 /tn "Security Script" /tr \\central\data\scripts\sec.vbs
  327. To schedule a task that runs every 100 minutes during non-business hours
  328.  
  329. The following command schedules 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. The command uses the /sc parameter to specify a minute schedule and the /mo parameter to specify an interval of 100 minutes. It uses the /st and /et parameters to specify the start time and end time of each day's schedule. It also uses the /k parameter to stop the script if it is still running at 7:59 A.M. Without /k, Schtasks would not start the script after 7:59 A.M., but if the instance started at 6:20 A.M. was still running, it would not stop it.
  330.  
  331. schtasks /create /tn "Security Script" /tr sec.vbs /sc minute /mo 100 /st 17:00 /et 08:00 /k
  332. To schedule a task that runs every N hours
  333. Hourly Schedule Syntax
  334.  
  335. schtasks /create /tn TaskName /tr TaskRun /sc hourly [/mo {1 - 23}] [/st HH**:MM] [/sd** StartDate] [/ed EndDate] [{/et HH**:MM | /du HHHH:MM} [/k**]] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  336. Remarks
  337.  
  338. In an hourly schedule, the /sc hourly parameter is required. The /mo (modifier) parameter is optional and specifies the number of hours between each run of the task. The default value for /mo is 1 (every hour). The /k (end task) parameter is optional and can be used with either /et (end at the specified time) or /du (end after the specified interval).
  339. Examples
  340. To schedule a task that runs every five hours
  341.  
  342. The following command schedules the MyApp program to run every five hours beginning on the first day of March 2002. It uses the /mo parameter to specify the interval and the /sd parameter to specify the start date. Because the command does not specify a start time, the current time is used as the start time.
  343.  
  344. 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).
  345.  
  346. schtasks /create /sc hourly /mo 5 /sd 03/01/2002 /tn "My App" /tr c:\apps\myapp.exe
  347. To schedule a task that runs every hour at five minutes past the hour
  348.  
  349. The following command schedules the MyApp program to run hourly beginning at five minutes past midnight. Because the /mo parameter is omitted, the command uses the default value for the hourly schedule, which is every (1) hour. If this command runs after 12:05 A.M., the program does not run until the next day.
  350.  
  351. schtasks /create /sc hourly /st 00:05 /tn "My App" /tr c:\apps\myapp.exe
  352. To schedule a task that runs every 3 hours for 10 hours
  353.  
  354. The following command schedules the MyApp program to run every 3 hours for 10 hours.
  355.  
  356. 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.
  357.  
  358. schtasks /create /tn "My App" /tr myapp.exe /sc hourly /mo 3 /st 00:00 /du 0010:00
  359.  
  360. 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.
  361. To schedule a task that runs every N days
  362. Daily Schedule Syntax
  363.  
  364. schtasks /create /tn TaskName /tr TaskRun /sc daily [/mo {1 - 365}] [/st HH**:MM] [/sd** StartDate] [/ed EndDate] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  365. Remarks
  366.  
  367. 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).
  368. Examples
  369. To schedule a task that runs every day
  370.  
  371. The following example schedules the MyApp program to run once a day, every day, at 8:00 A.M. until December 31, 2002. Because it omits the /mo parameter, the default interval of 1 is used to run the command every day.
  372.  
  373. 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)
  374.  
  375. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc daily /st 08:00 /ed 31/12/2002
  376. To schedule a task that runs every 12 days
  377.  
  378. The following example schedules the MyApp program to run every twelve days at 1:00 P.M. (13:00) beginning on December 31, 2002. The command uses the /mo parameter to specify an interval of two (2) days and the /sd and /st parameters to specify the date and time.
  379.  
  380. 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)
  381.  
  382. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc daily /mo 12 /sd 12/31/2002 /st 13:00
  383. To schedule a task that runs every 70 days if I am logged on
  384.  
  385. The following command schedules a security script, Sec.vbs, to run every 70 days. The command uses the /mo parameter to specify an interval of 70 days. It also uses the /it parameter to specify that the task runs only when the user under whose account the task runs is logged onto the computer. Because the task will run with the permissions of my user account, then the task will run only when I am logged on.
  386.  
  387. schtasks /create /tn "Security Script" /tr sec.vbs /sc daily /mo 70 /it
  388.  
  389. Note
  390.  
  391. 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.
  392.  
  393. To schedule a task that runs every N weeks
  394. Weekly Schedule Syntax
  395.  
  396. schtasks /create /tn TaskName /tr TaskRun /sc weekly [/mo {1 - 52}] [/d {MON - SUN[,MON - SUN...] | *}] [/st HH**:MM] [/sd** StartDate] [/ed EndDate] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  397. Remarks
  398.  
  399. 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).
  400.  
  401. 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.
  402. Examples
  403. To schedule a task that runs every six weeks
  404.  
  405. The following command schedules the MyApp program to run on a remote computer every six weeks. The command uses the /mo parameter to specify the interval. Because the command omits the /d parameter, the task runs on Mondays.
  406.  
  407. 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.
  408.  
  409. 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.
  410.  
  411. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc weekly /mo 6 /s Server16 /u Admin01
  412. To schedule a task that runs every other week on Friday
  413.  
  414. The following command schedules a task to run every other Friday. It 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, omit the /mo parameter or set it to 1.
  415.  
  416. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc weekly /mo 2 /d FRI
  417. To schedule a task that runs every N months
  418. Syntax
  419.  
  420. schtasks /create /tn TaskName /tr TaskRun /sc monthly [/mo {1 - 12}] [/d {1 - 31}] [/st HH**:MM] [/sd** StartDate] [/ed EndDate] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  421. Remarks
  422.  
  423. 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).
  424. Examples
  425. To schedule a task that runs on the first day of every month
  426.  
  427. The following command schedules the MyApp program to run on the first day of every month. Because a value of 1 is the default for both the /mo (modifier) parameter and the /d (day) parameter, these parameters are omitted from the command.
  428.  
  429. schtasks /create /tn "My App" /tr myapp.exe /sc monthly
  430. To schedule a task that runs every three months
  431.  
  432. The following command schedules the MyApp program to run every three months. It uses the /mo parameter to specify the interval.
  433.  
  434. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo 3
  435. To schedule a task that runs at midnight on the 21st day of every other month
  436.  
  437. The following command schedules the MyApp program to run every other month on the 21st day of the month at midnight. The command specifies that this task should run for one year, from July 2, 2002 to June 30, 2003.
  438.  
  439. 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.
  440.  
  441. 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
  442. To schedule a task that runs on a specific day of the week
  443. Weekly Schedule Syntax
  444.  
  445. schtasks /create /tn TaskName /tr TaskRun /sc weekly [/d {MON - SUN[,MON - SUN...] | *}] [/mo {1 - 52}] [/st HH**:MM] [/sd** StartDate] [/ed EndDate] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  446. Remarks
  447.  
  448. 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.
  449. Examples
  450. To schedule a task that runs every Wednesday
  451.  
  452. The following command schedules the MyApp program to run every week on Wednesday. The command uses the /d parameter to specify the day of the week. Because the command omits the /mo parameter, the task runs every week.
  453.  
  454. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc weekly /d WED
  455. To schedule a task that runs every eight weeks on Monday and Friday
  456.  
  457. The following command schedules a task to run on Monday and Friday of every eighth week. It uses the /d parameter to specify the days and the /mo parameter to specify the eight-week interval.
  458.  
  459. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc weekly /mo 8 /d MON,FRI
  460. To schedule a task that runs on a specific week of the month
  461. Specific Week Syntax
  462.  
  463. schtasks /create /tn TaskName /tr TaskRun /sc monthly /mo {FIRST | SECOND | THIRD | FOURTH | LAST} /d MON - SUN [/m {JAN - DEC[,JAN - DEC...] | *}] [/st HH**:MM] [/sd** StartDate] [/ed EndDate] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  464. Remarks
  465.  
  466. 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.
  467. Examples
  468. To schedule a task for the second Sunday of every month
  469.  
  470. The following command schedules the MyApp program to run on the second Sunday of every month. It uses the /mo parameter to specify the second week of the month and the /d parameter to specify the day.
  471.  
  472. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo SECOND /d SUN
  473. To schedule a task for the first Monday in March and September
  474.  
  475. The following command schedules the MyApp program to run on the first Monday in March and September. It uses the /mo parameter to specify the first week of the month and the /d parameter to specify the day. It uses /m parameter to specify the month, separating the month arguments with a comma.
  476.  
  477. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo FIRST /d MON /m MAR,SEP
  478. To schedule a task that runs on a specific date each month
  479. Specific date syntax
  480.  
  481. schtasks /create /tn TaskName /tr TaskRun /sc monthly /d {1 - 31} [/m {JAN - DEC[,JAN - DEC...] | *}] [/st HH**:MM] [/sd** StartDate] [/ed EndDate] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  482. Remarks
  483.  
  484. In the specific date 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. You can specify only one day in the schedule. The /mo (modifier) parameter is not valid with this schedule type.
  485.  
  486. 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.
  487. Examples
  488. To schedule a task for the first day of every month
  489.  
  490. The following command schedules the MyApp program to run on the first day of every month. Because the default modifier is none (no modifier), the default day is day 1, and the default month is every month, the command does not need any additional parameters.
  491.  
  492. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly
  493. To schedule a task for the 15th days of May and June
  494.  
  495. The following command schedules the MyApp program to run on May 15 and June 15 at 3:00 P.M. (15:00). It 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.
  496.  
  497. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /d 15 /m MAY,JUN /st 15:00
  498. To schedule a task that runs on a the last day of a month
  499. Last day syntax
  500.  
  501. schtasks /create /tn TaskName /tr TaskRun /sc monthly /mo LASTDAY /m {JAN - DEC[,JAN - DEC...]} [/st HH**:MM] [/sd** StartDate] [/ed EndDate] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  502. Remarks
  503.  
  504. 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 is not valid.
  505. Examples
  506. To schedule a task for the last day of every month
  507.  
  508. To run a program on the last day of every month, you must create three separate tasks. Each task will include months that have the same number of days. Each task uses the /mo parameter to specify the last day and the /m parameter to specify the months.
  509.  
  510. The following command schedules the MyApp program to run on the last day of every month that contains 31 days.
  511.  
  512. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo lastday /m JAN,MAR,MAY,JUL,AUG,OCT,DEC
  513.  
  514. The following command schedules the MyApp program to run on the last day of every month that contains 30 days.
  515.  
  516. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo lastday /m APR,JUN,SEP,NOV
  517.  
  518. The following command schedules the MyApp program to run on the last day of February.
  519.  
  520. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo lastday /m FEB
  521. To schedule a task at 6:00 P.M. on the last day of February
  522.  
  523. You can also schedule a task to run at a specific time on the last day of a month. The following command schedules the MyApp program to run at 6:00 P.M. on the last day of February. It uses the /mo parameter to specify the last day, the /m parameter to specify the month, and the /st parameter to specify the start time.
  524.  
  525. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /mo lastday /m FEB /st 18:00
  526. To schedule a task that runs once
  527. Syntax
  528.  
  529. schtasks /create /tn TaskName /tr TaskRun /sc once /st HH : MM [/sd StartDate] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  530. Remarks
  531.  
  532. In the run-once schedule type, the /sc once parameter is required. The /st parameter, which specifies the time that the task runs, is required. The /sd parameter, which specifies the date that the task runs, is optional. The /mo (modifier) and /ed (end date) parameters are not valid for this schedule type.
  533.  
  534. 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.
  535. Examples
  536. To schedule a task that runs one time
  537.  
  538. The following command schedules the MyApp program to run at midnight on January 1, 2003. It uses the /sc parameter to specify the schedule type and the /sd and st to specify the date and time.
  539.  
  540. 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.
  541.  
  542. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc once /sd 01/01/2003 /st 00:00
  543. To schedule a task that runs every time the system starts
  544. Syntax
  545.  
  546. schtasks /create /tn TaskName /tr TaskRun /sc onstart [/sd StartDate] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  547. Remarks
  548.  
  549. In the on-start schedule type, the /sc onstart parameter is required. The /sd (start date) parameter is optional and the default is the current date.
  550. Examples
  551. To schedule a task that runs when the system starts
  552.  
  553. The following command schedules the MyApp program to run every time the system starts, beginning on March 15, 2001:
  554.  
  555. 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.
  556.  
  557. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc onstart /sd 03/15/2001
  558. To schedule a task that runs when a user logs on
  559. Syntax
  560.  
  561. schtasks /create /tn TaskName /tr TaskRun /sc onlogon [/sd StartDate] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  562. Remarks
  563.  
  564. The "on logon" schedule type schedules a task that runs whenever any user logs on to the computer. In the "on logon" schedule type, the /sc onlogon parameter is required. The /sd (start date) parameter is optional and the default is the current date.
  565. Examples
  566. To schedule a task that runs when a user logs on to a remote computer
  567.  
  568. The following command schedules a batch file to run every time a user (any user) logs on to the remote computer. It uses the /s parameter to specify the remote computer. Because the command is remote, all paths in the command, including the path to the batch file, refer to a path on the remote computer.
  569.  
  570. schtasks /create /tn "Start Web Site" /tr c:\myiis\webstart.bat /sc onlogon /s Server23
  571. To schedule a task that runs when the system is idle
  572. Syntax
  573.  
  574. schtasks /create /tn TaskName /tr TaskRun /sc onidle /i {1 - 999} [/sd StartDate] [/it] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  575. Remarks
  576.  
  577. The "on idle" schedule type schedules a task that runs whenever there is no user activity during the time specified by the /i parameter. In the "on idle" schedule type, the /sc onidle parameter and the /i parameter are required. The /sd (start date) is optional and the default is the current date.
  578. Examples
  579. To schedule a task that runs whenever the computer is idle
  580.  
  581. The following command schedules the MyApp program to run whenever the computer is idle. It uses the required /i parameter to specify that the computer must remain idle for ten minutes before the task starts.
  582.  
  583. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc onidle /i 10
  584. To schedule a task that runs now
  585.  
  586. Schtasks does not have a "run now" option, but you can simulate that option by creating a task that runs once and starts in a few minutes.
  587. Syntax
  588.  
  589. schtasks /create /tn TaskName /tr TaskRun /sc once [/st HH**:MM] /sd MM/DD/YYYY [/it**] [/ru {[Domain**\]User [/rp** Password] | System}] [/s Computer [/u [Domain**\]User [/p** Password]]]
  590. Examples
  591. To schedule a task that runs a few minutes from now.
  592.  
  593. The following command schedules a task to run once, on November 13, 2002 at 2:18 P.M. local time.
  594.  
  595. 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.
  596.  
  597. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc once /st 14:18 /sd 11/13/2002
  598. To schedule a task that runs with different permissions
  599.  
  600. You can schedule tasks of all types to run with permissions of an alternate account on both the local and a remote computer. In addition to the parameters required for the particular schedule type, the /ru parameter is required and the /rp parameter is optional.
  601. Examples
  602. To run a task with Administrator permissions on the local computer
  603.  
  604. The following command schedules the MyApp program to run on the local computer. It uses the /ru to specify that the task should run with the permissions of the user's Administrator account (Admin06). In this example, the task is scheduled to run every Tuesday, but you can use any schedule type for a task run with alternate permissions.
  605.  
  606. schtasks /create /tn "My App" /tr myapp.exe /sc weekly /d TUE /ru Admin06
  607.  
  608. In response, SchTasks.exe prompts for the "run as" password for the Admin06 account and then displays a success message.
  609.  
  610. Please enter the run as password for Admin06: ********
  611.  
  612. SUCCESS: The scheduled task "My App" has successfully been created.
  613.  
  614. To run a task with alternate permissions on a remote computer
  615.  
  616. The following command schedules the MyApp program to run on the Marketing computer every four days.
  617.  
  618. The command uses the /sc parameter to specify a daily schedule and /mo parameter to specify an interval of four days.
  619.  
  620. 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.
  621.  
  622. schtasks /create /tn "My App" /tr myapp.exe /sc daily /mo 4 /s Marketing /u Marketing\Admin01 /ru Reskits\User01
  623.  
  624. 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.
  625.  
  626. Type the password for Marketing\Admin01:********
  627.  
  628. Please enter the run as password for Reskits\User01: ********
  629.  
  630. SUCCESS: The scheduled task "My App" has successfully been created.
  631.  
  632. To run a task only when a particular user is logged on
  633.  
  634. The following command schedules the AdminCheck.exe program to run on the Public computer every Friday at 4:00 A.M., but only if the administrator of the computer is logged on.
  635.  
  636. 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.
  637.  
  638. 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.
  639.  
  640. schtasks /create /tn "Check Admin" /tr AdminCheck.exe /sc weekly /d FRI /st 04:00 /s Public /u Domain3\Admin06 /ru Public\Admin01 /it
  641.  
  642. Note
  643.  
  644. 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.
  645.  
  646. To schedule a task that runs with system permissions
  647.  
  648. Tasks of all types can run with permissions of the System account on both the local and a remote computer. In addition to the parameters required for the particular schedule type, the /ru system (or /ru "") parameter is required and the /rp parameter is not valid.
  649.  
  650. Important
  651.  
  652. The System account does not have interactive logon rights. Users cannot see or interact with programs or tasks run with system permissions.
  653.  
  654. 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.
  655.  
  656. Note
  657.  
  658. 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.
  659.  
  660. Examples
  661. To run a task with system permissions
  662.  
  663. The following command schedules the MyApp program to run on the local computer with permissions of the System account. In this example, the task is scheduled to run on the fifteenth day of every month, but you can use any schedule type for a task run with system permissions.
  664.  
  665. 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.
  666.  
  667. schtasks /create /tn "My App" /tr c:\apps\myapp.exe /sc monthly /d 15 /ru System
  668.  
  669. In response, SchTasks.exe displays an informational message and a success message. It does not prompt for a password.
  670.  
  671. INFO: The task will be created under user name ("NT AUTHORITY\SYSTEM").
  672. SUCCESS: The Scheduled task "My App" has successfully been created.
  673.  
  674. To run a task with system permissions on a remote computer
  675.  
  676. The following command schedules the MyApp program to run on the Finance01 computer every morning at 4:00 A.M. with system permissions.
  677.  
  678. 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.
  679.  
  680. 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.
  681.  
  682. schtasks /create /tn "My App" /tr myapp.exe /sc daily /st 04:00 /s Finance01 /u Admin01 /ru System
  683.  
  684. 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.
  685.  
  686. Type the password for Admin01:**********
  687.  
  688. INFO: The Schedule Task "My App" will be created under user name ("NT AUTHORITY\
  689. SYSTEM").
  690. SUCCESS: The scheduled task "My App" has successfully been created.
  691.  
  692. To schedule a task that runs more than one program
  693.  
  694. Each task runs only one program. However, you can create a batch file that runs multiple programs and then schedule a task to run the batch file. The following procedure demonstrates this method:
  695.  
  696. Create a batch file that starts the programs you want to run.
  697.  
  698. In this example, you create a batch file that starts Event Viewer (Eventvwr.exe) and System Monitor (Perfmon.exe).
  699.  
  700. Open a text editor, such as Notepad.
  701.  
  702. Type the name and fully qualified path to the executable file for each program. In this case, the file includes the following statements.
  703.  
  704. C:\Windows\System32\Eventvwr.exe C:\Windows\System32\Perfmon.exe
  705.  
  706. Save the file as MyApps.bat.
  707.  
  708. Use SchTasks.exe to create a task that runs MyApps.bat.
  709.  
  710. 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.
  711.  
  712. schtasks /create /tn Monitor /tr C:\MyApps.bat /sc onlogon /ru Reskit\Administrator
  713.  
  714. As a result of this command, whenever a user logs on to the computer, the task starts both Event Viewer and System Monitor.
  715.  
  716. To schedule a task that runs on a remote computer
  717.  
  718. To schedule a task to run on a remote computer, you must add the task to the remote computer's schedule. Tasks of all types can be scheduled on a remote computer, but the following conditions must be met.
  719.  
  720. 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.
  721.  
  722. 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.
  723.  
  724. 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.
  725.  
  726. Examples
  727. An Administrator schedules a task on a remote computer
  728.  
  729. The following command schedules the MyApp program to run on the SRV01 remote computer every ten days starting immediately. The command uses the /s parameter to provide the name of the remote computer. Because the local current user is an Administrator of the remote computer, the /u parameter, which provides alternate permissions for scheduling the task, is not necessary.
  730.  
  731. 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.
  732.  
  733. schtasks /create /s SRV01 /tn "My App" /tr "c:\program files\corpapps\myapp.exe" /sc daily /mo 10
  734.  
  735. In response, Schtasks displays a success message indicating that the task is scheduled.
  736. A user schedules a command on a remote computer (Case 1)
  737.  
  738. The following command schedules the MyApp program to run on the SRV06 remote computer every three hours. Because Administrator permissions are required to schedule a task, the command uses the /u and /p parameters to provide the credentials of the user's Administrator account (Admin01 in the Reskits domain). By default, these permission are also used to run the task. However, because the task doesn't need Administrator permissions to run, the command includes the /ru and /rp parameters to override the default and run the task with permission of the user's non-Administrator account on the remote computer.
  739.  
  740. 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
  741.  
  742. In response, Schtasks displays a success message indicating that the task is scheduled.
  743. A user schedules a command on a remote computer (Case 2)
  744.  
  745. The following command schedules the MyApp program to run on the SRV02 remote computer on the last day of every month. Because the local current user (user03) is not an Administrator of the remote computer, the command uses the /u parameter to provide the credentials of the user's Administrator account (Admin01 in the Reskits domain). The Administrator account permissions will be used to schedule the task and to run the task.
  746.  
  747. schtasks /create /s SRV02 /tn "My App" /tr "c:\program files\corpapps\myapp.exe" /sc monthly /mo LASTDAY /m * /u reskits\admin01
  748.  
  749. 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.
  750.  
  751. Type the password for reskits\admin01:********
  752.  
  753. SUCCESS: The scheduled task "My App" has successfully been created.
  754.  
  755. WARNING: The Scheduled task "My App" has been created, but may not run because
  756. the account information could not be set.
  757.  
  758. 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.
  759.  
  760. 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.
  761.  
  762. 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.
  763.  
  764. HostName: SRV44
  765. TaskName: My App
  766. Next Run Time: Never
  767. Status:
  768. Logon mode: Interactive/Background
  769. Last Run Time: Never
  770. Last Result: 0
  771. Creator: user03
  772. Schedule: At 3:52 PM on day 31 of every month, start
  773. starting 12/14/2001
  774. Task To Run: c:\program files\corpapps\myapp.exe
  775. Start In: myapp.exe
  776. Comment: N/A
  777. Scheduled Task State: Disabled
  778. Scheduled Type: Monthly
  779. Start Time: 3:52:00 PM
  780. Start Date: 12/14/2001
  781. End Date: N/A
  782. Days: 31
  783. Months: JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NO
  784. V,DEC
  785. Run As User: Could not be retrieved from the task sched
  786. uler database
  787. Delete Task If Not Rescheduled: Enabled
  788. Stop Task If Runs X Hours and X Mins: 72:0
  789. Repeat: Every: Disabled
  790. Repeat: Until: Time: Disabled
  791. Repeat: Until: Duration: Disabled
  792. Repeat: Stop If Still Running: Disabled
  793. Idle Time: Disabled
  794. Power Management: Disabled
  795.  
  796. Remarks
  797.  
  798. 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.
  799.  
  800. To view more schtasks /create examples, type schtasks /create /? at a command prompt.
  801.  
  802. 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.
  803.  
  804. 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.
  805.  
  806. 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.
  807.  
  808. 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.
  809.  
  810. The System account does not have interactive logon rights. Users do not see and cannot interact with programs run with system permissions.
  811.  
  812. 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.
  813.  
  814. 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.
  815.  
  816. schtasks change
  817.  
  818. Changes one or more of the following properties of a task.
  819.  
  820. The program that the task runs (/tr).
  821.  
  822. The user account under which the task runs (/ru).
  823.  
  824. The password for the user account (/rp).
  825.  
  826. Adds the interactive-only property to the task (/it).
  827.  
  828. Syntax
  829.  
  830. schtasks /change /tn TaskName [/s Computer [/u [Domain**\]User [/p** Password]]] [/ru {[Domain**\]User | System}] [/rp** Password] [/tr TaskRun] [/st StartTime] [/ri Interval] [{/et EndTime | /du Duration} [/k]] [/sd StartDate] [/ed EndDate] [/{ENABLE | DISABLE}] [/it] [/z]
  831. Parameters
  832.  
  833. /tn TaskName
  834. Identifies the task to be changed. Enter the task name.
  835.  
  836. /s Computer
  837. Specifies the name or IP address of a remote computer (with or without backslashes). The default is the local computer.
  838.  
  839. /u [Domain\]User
  840. 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 specified user account must be a member of the Administrators group on the remote computer. The /u and /p parameters are valid only for changing a task on a remote computer (/s).
  841.  
  842. /p Password
  843. Specifies the password of the user account specified in the /u parameter. If you use the /u parameter, but omit the /p parameter or the password argument, Schtasks prompts you for a password.
  844.  
  845. The **/u** and **/p** parameters are valid only when you use **/s**.
  846.  
  847. /ru {[Domain\]User | System}
  848. Specifies to change the user account under which the task runs. For specifying the Local System account, valid entries are "", "NT AUTHORITY\SYSTEM", or "SYSTEM".
  849.  
  850. When you change the user account, you must also change the user password. If a command has an **/ru** parameter but not an **/rp** parameter, schtasks prompts for a new password.
  851.  
  852. Tasks run with permissions of the local system account do not require or prompt for a password.
  853.  
  854. /rp Password
  855. Specifies a new password for the existing user account, or the user account specified by the /ru parameter. This parameter is ignored with used with the local system account.
  856.  
  857. /tr TaskRun
  858. Changes the program that the task runs. Enter the fully qualified path and file name of an executable file, script file, or batch file. If you omit the path, schtasks assumes that the file is in the systemroot\System32 directory. The specified program replaces the original program run by the task.
  859.  
  860. /st Starttime
  861. Specifies the start time for the task, using the 24-hour time format, HH:mm. For example, a value of 14:30 is equivalent to the 12-hour time of 2:30 PM.
  862.  
  863. /ri Interval
  864. Specifies the repetition interval for the scheduled task, in minutes. Valid range is 1 - 599940 (599940 minutes = 9999 hours).
  865.  
  866. /et EndTime
  867. Specifies the end time for the task, using the 24-hour time format, HH:mm. For example, a value of 14:30 is equivalent to the 12-hour time of 2:30 PM.
  868.  
  869. /du Duration
  870. Specifies to close the task at the EndTime or Duration, if specified.
  871.  
  872. /k
  873. Stops the program that the task runs at the time specified by /et or /du. Without /k, Schtasks does not start the program again after it reaches the time specified by /et or /du, but it does not stop the program if it is still running. This parameter is optional and valid only with a MINUTE or HOURLY schedule.
  874.  
  875. /sd StartDate
  876. Specifies the first date on which the task should be run. The date format is mm/dd/yyyy.
  877.  
  878. /ed EndDate
  879. Specifies the last date on which the task should be run. The format is mm/dd/yyyy.
  880.  
  881. /ENABLE
  882. Specifies to enable the scheduled task.
  883.  
  884. /DISABLE
  885. Specifies to disable the scheduled task.
  886.  
  887. /it
  888. Specifies 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.
  889.  
  890. This parameter has no effect on tasks that run with system permissions or tasks that already have the interactive-only property set. You can not use a change command to remove the interactive-only property from a task.
  891.  
  892. By default, the "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.
  893.  
  894. /z
  895. Specifies to delete the task upon the completion of its schedule.
  896.  
  897. /?
  898. Displays help at the command prompt.
  899.  
  900. Remarks
  901.  
  902. The /tn and /s parameters identify the task. The /tr, /ru, and /rp parameters specify properties of the task that you can change.
  903.  
  904. 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.
  905.  
  906. 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.
  907.  
  908. 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.
  909.  
  910. The System account does not have interactive logon rights. Users do not see and cannot interact with programs run with system permissions.
  911.  
  912. 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.
  913.  
  914. Examples
  915. To change the program that a task runs
  916.  
  917. The following command changes the program that the Virus Check task runs from VirusCheck.exe to VirusCheck2.exe. This command uses the /tn parameter to identify the task and the /tr parameter to specify the new program for the task. (You cannot change the task name.)
  918.  
  919. schtasks /change /tn "Virus Check" /tr C:\VirusCheck2.exe
  920.  
  921. In response, SchTasks.exe displays the following success message:
  922.  
  923. SUCCESS: The parameters of the scheduled task "Virus Check" have been changed.
  924.  
  925. As a result of this command, the Virus Check task now runs VirusCheck2.exe.
  926. To change the password for a remote task
  927.  
  928. The following command changes the password of the user account for the RemindMe task on the remote computer, Svr01. The command uses the /tn parameter to identify the task and the /s parameter to specify the remote computer. It uses the /rp parameter to specify the new password, p@ssWord3.
  929.  
  930. 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.
  931.  
  932. schtasks /change /tn RemindMe /s Svr01 /rp p@ssWord3
  933.  
  934. In response, SchTasks.exe displays the following success message:
  935.  
  936. SUCCESS: The parameters of the scheduled task "RemindMe" have been changed.
  937.  
  938. As a result of this command, the RemindMe task now runs under its original user account, but with a new password.
  939. To change the program and user account for a task
  940.  
  941. The following command changes the program that a task runs and changes the user account under which the task runs. Essentially, it uses an old schedule for a new task. This command changes the ChkNews task, which starts Notepad.exe every morning at 9:00 A.M., to start Internet Explorer instead.
  942.  
  943. 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.
  944.  
  945. 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.
  946.  
  947. schtasks /change /tn ChkNews /tr "c:\program files\Internet Explorer\iexplore.exe" /ru DomainX\Admin01
  948.  
  949. In response, SchTasks.exe requests the password for the user account. It obscures the text you type, so the password is not visible.
  950.  
  951. Please enter the password for DomainX\Admin01:
  952.  
  953. 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.
  954.  
  955. In response, SchTasks.exe displays the following success message:
  956.  
  957. SUCCESS: The parameters of the scheduled task "ChkNews" have been changed.
  958.  
  959. As a result of this command, the ChkNews task now runs Internet Explorer with the permissions of an Administrator account.
  960. To change a program to the System account
  961.  
  962. The following command changes the SecurityScript task so that it runs with permissions of the System account. It uses the /ru "" parameter to indicate the System account.
  963.  
  964. schtasks /change /tn SecurityScript /ru ""
  965.  
  966. In response, SchTasks.exe displays the following success message:
  967.  
  968. INFO: The run as user name for the scheduled task "SecurityScript" will be changed to "NT AUTHORITY\SYSTEM".
  969. SUCCESS: The parameters of the scheduled task "SecurityScript" have been changed.
  970.  
  971. Because tasks run with System account permissions do not require a password, SchTasks.exe does not prompt for one.
  972. To run a program only when I am logged on
  973.  
  974. The following command adds the interactive-only property to MyApp, an existing task. This property assures that the task runs only when the "run as" user, that is, the user account under which the task runs, is logged on to the computer.
  975.  
  976. 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.
  977.  
  978. schtasks /change /tn MyApp /it
  979.  
  980. In response, SchTasks.exe displays the following success message.
  981.  
  982. SUCCESS: The parameters of the scheduled task "MyApp" have been changed.
  983.  
  984. schtasks run
  985.  
  986. Starts a scheduled task immediately. The run operation ignores the schedule, but uses the program file location, user account, and password saved in the task to run the task immediately.
  987. Syntax
  988.  
  989. schtasks /run /tn TaskName [/s Computer [/u [Domain**\]User [/p** Password]]]
  990. Parameters
  991.  
  992. /tn TaskName
  993. Required. Identifies the task.
  994.  
  995. /s Computer
  996. Specifies the name or IP address of a remote computer (with or without backslashes). The default is the local computer.
  997.  
  998. /u [Domain\]User
  999. Runs this command with the permissions of the specified user account. By default, the command runs with the permissions of the current user of the local computer.
  1000.  
  1001. The specified user account must be a member of the Administrators group on the remote computer. The **/u** and **/p** parameters are valid only when you use **/s**.
  1002.  
  1003. /p Password
  1004. Specifies the password of the user account specified in the /u parameter. If you use the /u parameter, but omit the /p parameter or the password argument, Schtasks prompts you for a password.
  1005.  
  1006. The **/u** and **/p** parameters are valid only when you use **/s**.
  1007.  
  1008. /?
  1009. Displays help at the command prompt.
  1010.  
  1011. Remarks
  1012.  
  1013. 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.
  1014.  
  1015. Running a task does not affect the task schedule and does not change the next run time scheduled for the task.
  1016.  
  1017. 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.
  1018.  
  1019. Examples
  1020. To run a task on the local computer
  1021.  
  1022. The following command starts the "Security Script" task.
  1023.  
  1024. schtasks /run /tn "Security Script"
  1025.  
  1026. In response, SchTasks.exe starts the script associated with the task and displays the following message:
  1027.  
  1028. SUCCESS: Attempted to run the scheduled task "Security Script".
  1029.  
  1030. As the message implies, Schtasks tries to start the program, but it cannot very that the program actually started.
  1031. To run a task on a remote computer
  1032.  
  1033. The following command starts the Update task on a remote computer, Svr01:
  1034.  
  1035. schtasks /run /tn Update /s Svr01
  1036.  
  1037. In this case, SchTasks.exe displays the following error message:
  1038.  
  1039. ERROR: Unable to run the scheduled task "Update".
  1040.  
  1041. 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:
  1042.  
  1043. "Update.job" (update.exe) 3/26/2001 1:15:46 PM ** ERROR **
  1044. The attempt to log on to the account associated with the task failed, therefore, the task did not run.
  1045. The specific error is:
  1046. 0x8007052e: Logon failure: unknown user name or bad password.
  1047. Verify that the task's Run-as name and password are valid and try again.
  1048.  
  1049. 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:
  1050.  
  1051. schtasks /change /tn Update /s Svr01 /ru Administrator /rp PassW@rd3
  1052.  
  1053. After the change command completes, the run command is repeated. This time, the Update.exe program starts and SchTasks.exe displays the following message:
  1054.  
  1055. SUCCESS: Attempted to run the scheduled task "Update".
  1056.  
  1057. As the message implies, Schtasks tries to start the program, but it cannot very that the program actually started.
  1058. schtasks end
  1059.  
  1060. Stops a program started by a task.
  1061. Syntax
  1062.  
  1063. schtasks /end /tn TaskName [/s Computer [/u [Domain**\]User [/p** Password]]]
  1064. Parameters
  1065.  
  1066. /tn TaskName
  1067. Required. Identifies the task that started the program.
  1068.  
  1069. /s Computer
  1070. Specifies the name or IP address of a remote computer. The default is the local computer.
  1071.  
  1072. /u [Domain\]User
  1073. Runs this command with the permissions of the specified user account. By default, the command runs with the permissions of the current user of the local computer.
  1074.  
  1075. The specified user account must be a member of the Administrators group on the remote computer. The **/u** and **/p** parameters are valid only when you use **/s**.
  1076.  
  1077. /p Password
  1078. Specifies the password of the user account specified in the /u parameter. If you use the /u parameter, but omit the /p parameter or the password argument, Schtasks prompts you for a password.
  1079.  
  1080. The **/u** and **/p** parameters are valid only when you use **/s**.
  1081.  
  1082. /?
  1083. Displays help.
  1084.  
  1085. Remarks
  1086.  
  1087. 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
  1088.  
  1089. Examples
  1090. To end a task on a local computer
  1091.  
  1092. The following command stops the instance of Notepad.exe that was started by the My Notepad task:
  1093.  
  1094. schtasks /end /tn "My Notepad"
  1095.  
  1096. In response, SchTasks.exe stops the instance of Notepad.exe that the task started, and it displays the following success message:
  1097.  
  1098. SUCCESS: The scheduled task "My Notepad" has been terminated successfully.
  1099.  
  1100. To end a task on a remote computer
  1101.  
  1102. The following command stops the instance of Internet Explorer that was started by the InternetOn task on the remote computer, Svr01:
  1103.  
  1104. schtasks /end /tn InternetOn /s Svr01
  1105.  
  1106. In response, SchTasks.exe stops the instance of Internet Explorer that the task started, and it displays the following success message:
  1107.  
  1108. SUCCESS: The scheduled task "InternetOn" has been terminated successfully.
  1109.  
  1110. schtasks delete
  1111.  
  1112. Deletes a scheduled task.
  1113. Syntax
  1114.  
  1115. schtasks /delete /tn {TaskName | *} [/f] [/s Computer [/u [Domain**\]User [/p** Password]]]
  1116. Parameters
  1117.  
  1118. /tn {TaskName| *}
  1119. Required. Identifies the task being deleted.
  1120.  
  1121. <table>
  1122. <colgroup>
  1123. <col style="width: 50%" />
  1124. <col style="width: 50%" />
  1125. </colgroup>
  1126. <thead>
  1127. <tr class="header">
  1128. <th>Value</th>
  1129. <th>Description</th>
  1130. </tr>
  1131. </thead>
  1132. <tbody>
  1133. <tr class="odd">
  1134. <td><p><em>TaskName</em></p></td>
  1135. <td><p>Deletes the named task.</p></td>
  1136. </tr>
  1137. <tr class="even">
  1138. <td><p><em>*</em></p></td>
  1139. <td><p>Deletes all scheduled tasks on the computer.</p></td>
  1140. </tr>
  1141. </tbody>
  1142. </table>
  1143.  
  1144. /f
  1145. Suppresses the confirmation message. The task is deleted without warning.
  1146.  
  1147. /s Computer
  1148. Specifies the name or IP address of a remote computer (with or without backslashes). The default is the local computer.
  1149.  
  1150. /u [Domain\]User
  1151. Runs this command with the permissions of the specified user account. By default, the command runs with the permissions of the current user of the local computer.
  1152.  
  1153. The specified user account must be a member of the Administrators group on the remote computer. The **/u** and **/p** parameters are valid only when you use **/s**.
  1154.  
  1155. /p Password
  1156. Specifies the password of the user account specified in the /u parameter. If you use the /u parameter, but omit the /p parameter or the password argument, Schtasks prompts you for a password.
  1157.  
  1158. The **/u** and **/p** parameters are valid only when you use **/s**.
  1159.  
  1160. /?
  1161. Displays help at the command prompt.
  1162.  
  1163. Remarks
  1164.  
  1165. The delete operation deletes the task from the schedule. It does not delete the program that the task runs or interrupt a running program.
  1166.  
  1167. The delete * command deletes all tasks scheduled for the computer, not just the tasks scheduled by the current user.
  1168.  
  1169. Examples
  1170. To delete a task from the schedule of a remote computer
  1171.  
  1172. The following command deletes the "Start Mail" task from the schedule of a remote computer. It uses the /s parameter to identify the remote computer.
  1173.  
  1174. schtasks /delete /tn "Start Mail" /s Svr16
  1175.  
  1176. In response, SchTasks.exe displays the following confirmation message. To delete the task, type y. To cancel the command, type n:
  1177.  
  1178. WARNING: Are you sure you want to remove the task "Start Mail" (Y/N )?
  1179. SUCCESS: The scheduled task "Start Mail" was successfully deleted.
  1180.  
  1181. To delete all tasks scheduled for the local computer
  1182.  
  1183. The following command deletes all tasks from the schedule of the local computer, including tasks scheduled by other users. It uses the /tn * parameter to represent all tasks on the computer and the /f parameter to suppress the confirmation message.
  1184.  
  1185. schtasks /delete /tn * /f
  1186.  
  1187. In response, SchTasks.exe displays the following success messages indicating that the only task scheduled, SecureScript, is deleted.
  1188.  
  1189. SUCCESS: The scheduled task "SecureScript" was successfully deleted.
  1190. schtasks query
  1191.  
  1192. Displays tasks scheduled to run on the computer.
  1193. Syntax
  1194.  
  1195. Schtasks [/query] [/fo {TABLE | LIST | CSV}] [/nh] [/v] [/s Computer [/u [Domain**\]User [/p** Password]]]
  1196. Parameters
  1197.  
  1198. [/query]
  1199. The operation name is optional. Typing schtasks without any parameters performs a query.
  1200.  
  1201. /fo {TABLE| LIST| CSV}
  1202. Specifies the output format. TABLE is the default.
  1203.  
  1204. /nh
  1205. Omits column headings from the table display. This parameter is valid with the TABLE and CSV output formats.
  1206.  
  1207. /v
  1208. Adds advanced properties of the tasks to the display.
  1209.  
  1210. Queries using **/v** should be formatted as **LIST** or **CSV**.
  1211.  
  1212. /s Computer
  1213. Specifies the name or IP address of a remote computer (with or without backslashes). The default is the local computer.
  1214.  
  1215. /u [Domain\]User
  1216. Runs this command with the permissions of the specified user account. By default, the command runs with the permissions of the current user of the local computer.
  1217.  
  1218. The specified user account must be a member of the Administrators group on the remote computer. The **/u** and **/p** parameters are valid only when you use **/s**.
  1219.  
  1220. /p Password
  1221. Specifies the password of the user account specified in the /u parameter. If you use /u, but omit /p or the password argument, Schtasks prompts you for a password.
  1222.  
  1223. The **/u** and **/p** parameters are valid only when you use **/s**.
  1224.  
  1225. /?
  1226. Displays help at the command prompt.
  1227.  
  1228. Remarks
  1229.  
  1230. 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.
  1231.  
  1232. Examples
  1233. To display the scheduled tasks on the local computer
  1234.  
  1235. The following commands display all tasks scheduled for the local computer. These commands produce the same result and can be used interchangeably.
  1236.  
  1237. schtasks
  1238.  
  1239. schtasks /query
  1240.  
  1241. In response, SchTasks.exe displays the tasks in the default, simple table format, as shown in the following table:
  1242.  
  1243. TaskName Next Run Time Status
  1244. ========================= ======================== ==============
  1245. Microsoft Outlook At logon time
  1246. SecureScript 14:42:00 PM , 2/4/2001
  1247.  
  1248. To display advanced properties of scheduled tasks
  1249.  
  1250. The following command requests a detailed display of the tasks on the local computer. It uses the /v parameter to request a detailed (verbose) display and the /fo LIST parameter to format the display as a list for easy reading. You can use this command to verify that a task you created has the intended recurrence pattern.
  1251.  
  1252. schtasks /query /fo LIST /v
  1253.  
  1254. 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:
  1255.  
  1256. HostName: RESKIT01
  1257. TaskName: SecureScript
  1258. Next Run Time: 4:00:00 AM , 3/30/2001
  1259. Status: Not yet run
  1260. Logon mode: Interactive/Background
  1261. Last Run Time: Never
  1262. Last Result: 0
  1263. Creator: user01
  1264. Schedule: At 4:00 AM on the last Fri of every month, starting 3/24/2001
  1265. Task To Run: C:\WINDOWS\system32\notepad.exe
  1266. Start In: notepad.exe
  1267. Comment: N/A
  1268. Scheduled Task State: Enabled
  1269. Scheduled Type: Monthly
  1270. Modifier: Last FRIDAY
  1271. Start Time: 4:00:00 AM
  1272. Start Date: 3/24/2001
  1273. End Date: N/A
  1274. Days: FRIDAY
  1275. Months: JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC
  1276. Run As User: RESKIT\user01
  1277. Delete Task If Not Rescheduled: Enabled
  1278. Stop Task If Runs X Hours and X Mins: 72:0
  1279. Repeat: Until Time: Disabled
  1280. Repeat: Duration: Disabled
  1281. Repeat: Stop If Still Running: Disabled
  1282. Idle: Start Time(For IDLE Scheduled Type): Disabled
  1283. Idle: Only Start If Idle for X Minutes: Disabled
  1284. Idle: If Not Idle Retry For X Minutes: Disabled
  1285. Idle: Stop Task If Idle State End: Disabled
  1286. Power Mgmt: No Start On Batteries: Disabled
  1287. Power Mgmt: Stop On Battery Mode: Disabled
  1288.  
  1289. To log tasks scheduled for a remote computer
  1290.  
  1291. The following command requests a list of tasks scheduled for a remote computer, and adds the tasks to a comma-separated log file on the local computer. You can use this command format to collect and track tasks that are scheduled for multiple computers.
  1292.  
  1293. 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.
  1294.  
  1295. schtasks /query /s Reskit16 /fo csv /nh >> \\svr01\data\tasklogs\p0102.csv
  1296.  
  1297. In response, SchTasks.exe adds the tasks scheduled for the Reskit16 computer to the p0102.csv file on the local computer, Svr01.
  1298. Remarks
  1299.  
  1300. 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.
  1301.  
  1302. SchTasks.exe performs the same operations as Scheduled Tasks in Control Panel. You can use these tools together and interchangeably.
  1303.  
  1304. 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.
  1305.  
  1306. The parameters in a Schtasks command can appear in any order. Typing schtasks without any parameters performs a query.
  1307.  
  1308. Permissions for Schtasks
  1309.  
  1310. 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.
  1311.  
  1312. 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.
  1313.  
  1314. 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.
  1315.  
  1316. 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.
  1317.  
  1318. 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.
  1319.  
  1320. 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:
  1321. ------------------------------------------------------------------------------------
  1322. How to create scheduled tasks with Command Prompt on Windows 7&10
  1323. ----------------------------------------------------------------------------------------
  1324. How to create a scheduled task using Command Prompt
  1325.  
  1326. To create a scheduled task with Command Prompt on Windows 10, use these steps:
  1327. RECOMMENDED VIDEOS FOR YOU...
  1328.  
  1329. 1 Open Start.
  1330. 2 Search for Command Prompt, right-click the top result, and select the Run as administrator option.
  1331. 3 Type the following command to create a daily task to run an app at 11:00am and press Enter:SyntaxSCHTASKS /CREATE /SC DAILY /TN "FOLDERPATH\TASKNAME" /TR "C:\SOURCE\FOLDER\APP-OR-SCRIPT" /ST HH:MMExampleSCHTASKS /CREATE /SC DAILY /TN "MyTasks\Notepad task" /TR "C:\Windows\System32\notepad.exe" /ST 11:00Quick tip: The folder path before the task name, under the /TN option, is not a requirement, but it'll help you to keep your tasks separate. If you don't specify a path, the task will be created inside the Task Scheduler Library folder.
  1332.  
  1333. 4 Type the following command to create a weekly task to run an app at 11:00am and press Enter:SyntaxSCHTASKS /CREATE /SC WEEKLY /D SUN /TN "FOLDERPATH\TASKNAME" /TR "C:\SOURCE\FOLDER\APP-OR-SCRIPT" /ST HH:MMExampleSCHTASKS /CREATE /SC WEEKLY /D SUN /TN "MyTasks\Notepad task" /TR "C:\Windows\System32\notepad.exe" /ST 11:00
  1334.  
  1335. 5 Type the following command to create a monthly task to run an app at 11:00am and press Enter:SyntaxSCHTASKS /CREATE /SC MONTHLY /D 15 /TN "FOLDERPATH\TASKNAME" /TR "C:\SOURCE\FOLDER\APP-OR-SCRIPT" /ST HH:MMExampleSCHTASKS /CREATE /SC MONTHLY /D 15 /TN "MyTasks\Notepad task" /TR "C:\Windows\System32\notepad.exe" /ST 11:00
  1336.  
  1337. 6 Type the following command to create a scheduled task that runs daily as a specific user and press Enter:SyntaxSCHTASKS /CREATE /SC DAILY /TN "FOLDERPATH\TASKNAME" /TR "C:\SOURCE\FOLDER\APP-OR-SCRIPT" /ST HH:MM /RU USER-ACCOUNTExampleSCHTASKS /CREATE /SC DAILY /TN "MyTasks\Notepad task" /TR "C:\Windows\System32\notepad.exe" /ST 11:00 /RU admin
  1338.  
  1339. Once you complete the steps, the task will run during the intervals you specified.
  1340. Task Scheduler create options
  1341.  
  1342. The command line version of Task Scheduler ships with many options allowing to customize many aspects of a task, and in this guide, we are using the following options to change a scheduled task:
  1343.  
  1344. /CREATE — specifies that you want to create a new an automated routine.
  1345. /SC — defines the schedule for the task. Options available, include MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE, and ONEVENT.
  1346. /D — specifies the day of the week to execute the task. Options available, include MON, TUE, WED, THU, FRI, SAT, and SUN. If you're using the MONTHLY option, then you can use 1 - 31 for the days of the month. Also, there's the wildcard "*" that specifies all days.
  1347. /TN — specifies the task name and location. The "MyTasks\Notepad task" uses the "Notepad task" as the name and stores the task in the "MyTasks" folder. If the folder isn't available, it'll be created automatically.
  1348. /TR — specifies the location and the name of the task that you want to run. You can select an app or custom script.
  1349. /ST — defines the time to run the task (in 24 hours format).
  1350. /QUERY — displays all the system tasks.
  1351. /RU — specifies the task to run under a specific user account.
  1352.  
  1353. These are just some of the available options. You can learn more about the options to create a scheduled task running the
  1354.  
  1355. SCHTASKS /CREATE /?
  1356.  
  1357. command.
  1358. How to change a scheduled task using Command Prompt
  1359.  
  1360. To modify a scheduled task on Windows 10 with Command Prompt, use these steps:
  1361.  
  1362. 1 Open Start.
  1363. 2 Search for Command Prompt, right-click the top result, and select the Run as administrator option.
  1364. 3 Type the following command to change the time to run the task 9:00am and press Enter:SyntaxSCHTASKS /CHANGE /TN "FOLDERPATH\TASKNAME" /ST HH:MMExampleSCHTASKS /CHANGE /TN "MyTasks\Notepad task" /ST 09:00
  1365.  
  1366. 4 Type the following command to change the task user information and press Enter:SyntaxSCHTASKS /CHANGE /TN "FOLDERPATH\TASKNAME" /RU NEW-USERNAMEExampleSCHTASKS /CHANGE /TN "MyTasks\Notepad task" /RU admin2
  1367.  
  1368. 5 Type the following command to disable a scheduled task and press Enter:SyntaxSCHTASKS /CHANGE /TN "FOLDERPATH\TASKNAME" /DISABLEExampleSCHTASKS /CHANGE /TN "MyTasks\Notepad task" /DISABLEQuick tip: If you want to re-enable the task, you can use the same command, but make sure to use the /ENABLE option instead.
  1369.  
  1370. After completing the steps, the task will be modified with the information that you've specified.
  1371. Task Scheduler change options
  1372.  
  1373. In this guide, we are using the following options to create a scheduled task:
  1374.  
  1375. /CHANGE — specifies that you want to edit an existing task.
  1376. /TN — specifies the name and location of the task that you want to modify.
  1377. /ST — defines the new time to run the automated routine.
  1378. /DISABLE — disables the task.
  1379.  
  1380. These are just some of the available options. You can learn more about the options to change a scheduled task running the
  1381.  
  1382. SCHTASKS /CHANGE /?
  1383.  
  1384. command.
  1385. How to delete a scheduled task using Command Prompt
  1386.  
  1387. If you no longer need a particular task, you can delete it using these steps:
  1388.  
  1389. 1 Open Start.
  1390. 2 Search for Command Prompt, right-click the top result, and select the Run as administrator option.
  1391. 3 Type the following command to delete a scheduled task and press Enter:SyntaxSchTask /DELETE /TX "FOLDERPATH\TASKNAME"ExampleSCHTASKS /DELETE /TN "MyTasks\Notepad task"
  1392.  
  1393. Press the Y key to confirm.
  1394.  
  1395. Once you complete the steps, the task will be removed, and it'll no longer be available on your device.
  1396. Task Scheduler delete options
  1397.  
  1398. In this guide, we are using the following options to delete a scheduled task:
  1399.  
  1400. /DELETE — specifies that you want to delete an existing task.
  1401. /TN — specifies the name and location of the task that you want to delete.
  1402.  
  1403. We're focusing this guide on Windows 10, but the ability to use Task Scheduler with Command Prompt has been around for a long time, which means that you can also use these steps on Windows 8.1 and Windows 7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement