Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating dependencies in task scheduler

I have set up a couple of daily tasks that update a SQL table and then sends out an email with a CSV attached. 5 of the scheduled tasks only complete successfully if the first task runs successfully. How would I add an argument in Task Scheduler to run the sequential tasks only if the first task was completed successfully? The reasoning behind the request is due to the issue that sometimes the first script runs in a few minutes and other days it can take over an hour to complete. Any suggestions? Thank you

like image 703
AndrewMo Avatar asked Sep 02 '25 15:09

AndrewMo


1 Answers

It can be done! See here http://blogs.msdn.com/b/davethompson/archive/2011/10/25/running-a-scheduled-task-after-another.aspx

In summary though say you have a task called Ping and you want a task called pong to run after it.

  1. Create a task called Pong
  2. Create an On an Event Trigger
  3. Select Custom and edit the XML to be something like this
     <QueryList>
        <Query Id="0" Path="Microsoft-Windows-TaskScheduler/Operational">
           <Select Path="Microsoft-Windows-TaskScheduler/Operational">*[EventData
     [@Name='TaskSuccessEvent'][Data[@Name='TaskName']='\Ping']]</Select>
        </Query>
     </QueryList>
like image 50
David Hayes Avatar answered Sep 05 '25 14:09

David Hayes