0

As we know in SQL job agent, we can manage the control of steps

for ex:-
lets a job has following steps:-
step 1
step 2
step 3
step 4

we can control the flow as if step1 is success go to step 2 else go to step 4

Can something like this be done in task schedule?

because in task schduler, i did not find any option to perform this functionality

Any help in this regard?

Tyler Durden
  • 207
  • 1
  • 5
  • 10
  • I don't think the Windows Task Scheculer allows this. It only runs commands based on triggers you define. You can make steps in the script you run with it though. Or make multiple scripts. – sodawillow Oct 17 '15 at 07:26
  • Yeah.. but is there any add-in to task scheduler or something like that which can be used to perform this functionality – Tyler Durden Oct 17 '15 at 07:50

1 Answers1

0

As detailed in this MSDN blog post, you can chain tasks together by setting up a custom event trigger and use the XPath Filter editor to target events indicating that the previous task completed:

enter image description here

The TaskName value is the path to the task in Task Scheduler, so if you want to trigger on a task called "Task01", placed in the root folder of the task scheduler library, value should be "\Task01"

Unfortunately, the New-ScheduledTaskTrigger cmdlet doesn't support custom event log based triggers, so the only way to automate deployment of such a task is to:

  1. Create it "by hand"
  2. Export it
  3. Update the XML if necessary
  4. Import on target machine

Step 2-4 can be accomplished programmatically with Export-ScheduledTask, the [xml] type accelerator and schtasks /create /xml

Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
  • hey i followed the above mention approach but the task is getting triggred even if the previous task does not success – Tyler Durden Oct 19 '15 at 05:12