Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a backup task that fails with a non zero result, yet Task Scheduler says that it executed the task correctly.

Is there any way to tell Task Scheduler that the task failed?

share|improve this question
Hi Pablo, We'll need more info. Like how/what is the task scheduler launching? A batch file, an EXE, something else? Is this Windows Backup that you're dealing with? What have you tried? – Ƭᴇcʜιᴇ007 Sep 1 '11 at 15:00
I'm using the wbadmin program to start the backup, but I have the same problem with a batch file with a single 'exit 1' statement. The TaskScheduler includes the error code, but reports the Task as successfully ran. – Pablo Montilla Sep 1 '11 at 17:14
So the Task Scheduler itself shows the non-zero exit code? – Ƭᴇcʜιᴇ007 Sep 1 '11 at 17:19
Yes, but reports the task as executed successfuly. I gather that maybe it's reporting that it could execute the task, not that the task itself failed, but doesn't seem very useful. – Pablo Montilla Sep 2 '11 at 12:22
up vote 0 down vote accepted

If Task Scheduler successfully launches the task and the launched program exits, then from the point of view of the Task Scheduler it was a success (i.e., nothing bad happened like a failed user credential starting the program).

Normally if you want to monitor for something bad that happened during a program run you would either have the program send an alert of some sort (e.g., via email or by logging to a file that you later review), or else setup another program to monitor something about the program run that could indicate whether an error occurred.

What sort of notification of an error are you trying to get? Are you doing a manual review but just trying to have the error be more noticeable? Or do you have another program monitoring for errors?

share|improve this answer
Still I think it's wrong to fail and not report (or at least give an option to report) failure of the executed task. Thanks! – Pablo Montilla Feb 13 '12 at 11:35
I agree it would be useful if the Task Scheduler could detect the exit code and send an email based on the result. But I don't believe it has that feature. Are you trying to get an email alert? Maybe wrapping the launch of wbadmin in a VBScript or PowerShell script that would detect the exit code and do something with it would be a possibility for you? – Shannon Wagner Feb 16 '12 at 19:23
Yup, that is a possibility. It's also work...;) Hopefully MS will think this is something useful to add to Windows 8. – Pablo Montilla Feb 17 '12 at 12:25
This is mind-blowing to me - Task scheduler has all those options for configuring restart of an action in the event that it 'fails', but doesn't even check if an action returns an error code. Makes me wonder what on earth actually constitutes a 'failure' for the Task Scheduler. – mackenir Aug 22 '13 at 11:37
In light of this answer, I have to ask: does Task Scheduler even trigger a retry based on exit code? – jpmc26 Jun 7 at 3:58

It is possible to "restart" the task if it fails.

  1. Use following code in the batch script to create a system error event:

    eventcreate /ID 100 /SO "Your Script Name" /L APPLICATION /T ERROR /D "Your failure reason"

  2. Create a new task with a trigger that monitors the system events and filter for the category and ID you just added in the batch. The action of this task is the batch again. This task should be delayed by one minute, so that the same batch is not started twice!

Be careful not to create an infinite loop.

Hope that helps!

share|improve this answer
I like this approach :) – DavidPostill 2 days ago

You must log in to answer this question.

protected by Community 2 days ago

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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