{"id":699,"date":"2017-07-25T13:51:50","date_gmt":"2017-07-25T12:51:50","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=613"},"modified":"2017-07-25T13:51:50","modified_gmt":"2017-07-25T12:51:50","slug":"task-scheduler","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/windows-10-iot-core\/windows-iot-general\/os-tasks\/task-scheduler","title":{"rendered":"Task Scheduler"},"content":{"rendered":"<h4>\n\tPowershell commands<br \/>\n<\/h4>\n<p>\n\tView the current list of scheduled tasks\n<\/p>\n<pre>\n<code>\nschtasks.exe\n<\/code><\/pre>\n<h5>\n\tHelp<br \/>\n<\/h5>\n<p>\n\tFor a full list of supported parameters\n<\/p>\n<pre>\n<code>\nschtasks.exe \/?\n<\/code><\/pre>\n<pre>\n<code>\n<\/code><\/pre>\n<h5>\n\tCreate a new scheduled task<br \/>\n<\/h5>\n<pre>\n<code>\nschtasks \/Create \/?\nschtasks \/Create \/SC ONSTART \/TN MyTaskName \/TR &quot;some command to exectute or path to a batchfile&quot;\n<\/code><\/pre>\n<p>\n\tRun as Administrator:\n<\/p>\n<pre>\n<code>\nschtasks \/Create \/SC ONSTART \/TN MyTaskName \/TR &quot;some command to exectute or path to a batchfile&quot; \/RU SYSTEM\n<\/code><\/pre>\n<h5>\n\tDelete scheduled task<br \/>\n<\/h5>\n<pre>\n<code>\nschtasks \/Delete \/TN MyTaskName\n<\/code><\/pre>\n<h5>\n\tDisplays scheduled tasks<br \/>\n<\/h5>\n<pre>\n<code>\nschtasks \/Query\nschtasks \/Query \/TN MyTaskName\n<\/code><\/pre>\n<h5>\n\tChange the properties of scheduled task<br \/>\n<\/h5>\n<pre>\n<code>\nschtasks \/Change \/?\n<\/code><\/pre>\n<h5>\n\tRun scheduled task on demand<br \/>\n<\/h5>\n<pre>\n<code>\nschtasks \/Run \/TN MyTaskName\n<\/code><\/pre>\n<h5>\n\tStop currently running scheduled task<br \/>\n<\/h5>\n<pre>\n<code>\nschtasks \/End\n<\/code><\/pre>\n<h4>\n\tAdding a task to to the OS task scheduler<br \/>\n<\/h4>\n<p>\n\tschtasks is in System32 if it&#039;s not already in your path.\n<\/p>\n<p>\n\tschtasks can be run either on startup, timed, or as a one off execution\n<\/p>\n<p>\n\tFull paths are needed in schtasks.\n<\/p>\n<h4>\n\tExamples<br \/>\n<\/h4>\n<pre>\n<code>\nschtasks \/Create \/SC ONSTART \/TN TimeSync \/TR &quot;w32tm \/resync&quot;\n<\/code><\/pre>\n<p>\n\tThis forces a time re-sync. &nbsp;You could replace the \/TR with a script rather than a direct command.\n<\/p>\n<h4>\n\tTriggering running of a batch file<br \/>\n<\/h4>\n<p>\n\tBatch files need&nbsp;to be ANSI not Unicode.\n<\/p>\n<p>\n\tTesting powershell script when run through powershell command line can have errors and still complete, but when running as script file from task scheduler can &quot;shells out&quot; and stop&nbsp;when reaching an error in the file, so ensure you include error handling if needed.\n<\/p>\n<p>\n\tFull paths are needed in schtasks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Powershell commands View the current list of scheduled tasks schtasks.exe Help For a full list of supported parameters schtasks.exe \/? Create a new scheduled task schtasks \/Create \/? schtasks \/Create \/SC ONSTART \/TN MyTaskName \/TR &quot;some command to exectute or path to a batchfile&quot; Run as Administrator: schtasks \/Create \/SC ONSTART \/TN MyTaskName \/TR &quot;some [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[95],"tags":[],"class_list":["post-699","post","type-post","status-publish","format-standard","hentry","category-os-tasks"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/699","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=699"}],"version-history":[{"count":0,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/699\/revisions"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}