Win7中的Windows任务计划程序如何识别失败的任务? [英] How does Windows Task Scheduler in Win7 recognize a failed task?

查看:39
本文介绍了Win7中的Windows任务计划程序如何识别失败的任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Windows 7,并且我有一个应用程序在成功时返回零 (0x0),在错误情况下返回一 (0x1).

I am working with Windows 7 and I have an application that returns zero (0x0) when successful and one (0x1) on error situations.

我已使用 Windows 任务计划程序计划了此应用程序.我已经检查了选项框如果任务失败,重新启动每个"和尝试重新启动到:".

I have scheduled this app using Windows Task Scheduler. I have checked the option boxes "If the task fails, restart every" and "Attempt to restart up to:".

我认为应用程序的非零返回码足以触发任务在给定时间间隔后重新启动.但是什么也没发生.

I thought that a non-zero return code from the app would be enough to trigger the task to be restarted after the given interval. But nothing happens.

任何想法可能是什么问题?我尝试用谷歌搜索,但没有找到任何相关内容.

Any ideas what could be the issue? I tried to google it but did not found anything relevant.

推荐答案

创建一个新任务并设置自定义事件查询如下:

Create a new task and set the custom event query like this:

<QueryList>
  <Query Id="0" Path="Microsoft-Windows-TaskScheduler/Operational">
    <Select Path="Microsoft-Windows-TaskScheduler/Operational">*[System[EventID=201]] and *[EventData[Data[@Name='ResultCode']!='0']] and *[EventData[Data[@Name='TaskName']='YOUR TASK NAME HERE']]</Select>
  </Query>
</QueryList>

将触发器高级设置设置为将任务延迟一段时间,例如 15 分钟.

Set the trigger advanced settings to Delay the task for a period of time like 15 minutes.

配置新任务的动作以启动程序:

Configure the action of the new task to start a program:

程序/脚本:

schtasks

添加参数:

/Run /TN "YOUR TASK NAME HERE"

这将安排原始任务在事件中记录非零结果代码 15 分钟后再次运行.

This will schedule the original task to run again 15 minutes after a non-zero result code is logged in the event.

这篇关于Win7中的Windows任务计划程序如何识别失败的任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆