0

If you have a Windows Tasks Schedule Task with multiple actions, how does it run them?

Does it kick off each additional action without waiting for the previous action to finish, or does it wait until the prior actions complete before starting the next?

If a prior action fails to run, will later actions be skipped or will they run anyway? Is there a way to set this behavior?

I'm asking because I'm in the process of migrating some scheduled tasks from an old server to a new server. One of the tasks has about a dozen actions, and as I look through them I'm concerned some bad assumptions where regarding how these run. (Bad former Joel, bad!)

1 Answer 1

0

To find the answer, I made a scheduled task with three actions to each run a powershell script that looks like below, where the only difference is each script file sets the appropriate value for $ActionNum:

$ActionNum = 1
ac C:\users\public\log$ActionNum.txt "$(get-date) -- Test $ActionNum Start"
start-sleep -seconds 10
ac C:\users\public\log$ActionNum.txt "$(get-date) -- Test $ActionNum Stop"

I then ran the task, and I observed the timestamps in the second and third log files indicate each action starts only after the prior action completes.

Then I renamed the middle script file, so the action would fail, and ran it again. I checked the log files, and observed the third action still ran after the first.

I did not see a way in the Task Scheduler interface to change this behavior. If you need later actions to only run if earlier actions are successful, you may need to build this into the actions themselves.

I did see it might be possible to use multiple tasks, where later tasks are triggered by logging an event instead of on a schedule, where you could have prior tasks log a custom event. But even if you have the ability to modify an action this way, it seems like more work than just building into the prior action to launch the next.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .