简体   繁体   English

Windows 计划任务在重新启动后不起作用

[英]Windows Scheduled Task not working after a reboot

I have created scheduled tasks to run each day at various times in the morning, on 6 different machines, all running Windows 7 x64.我创建了每天早上不同时间运行的计划任务,在 6 台不同的机器上运行,所有机器都运行 Windows 7 x64。

These tasks have largely worked over the last few years, but we have a persisting issue with tasks not triggering at times, and never after a restart.这些任务在过去几年中大部分都有效,但我们一直存在一个问题,即任务有时不会触发,并且在重新启动后也不会触发。

Without touching the Task Scheduler application at all, restarting the machine will mean that the next time the task is meant to be triggered, it doesn't work.完全不接触任务计划程序应用程序,重新启动机器将意味着下次要触发该任务时,它就不起作用了。

Running any task manually after the restart appears to avoid the issue.重新启动后手动运行任何任务似乎可以避免该问题。

This issue exists for scheduled batch files and PowerShell scripts.计划的批处理文件和 PowerShell 脚本存在此问题。

Is there a specific setting that is needed to keep the task working after a system restart, or is this a known outstanding issue?是否需要特定设置才能在系统重新启动后保持任务正常工作,或者这是一个已知的突出问题?

The most recent time this happened, we have captured the history:最近一次发生这种情况时,我们捕获了历史记录:

Error       | 27/02/2017 03:15:00 | 101 | Task Start Failed
Information | 27/02/2017 03:15:00 | 107 | Task triggered on Scheduler

Result code for failure: 2147943645

Update 2017-03-01: One machine doesn't work and produces the above error, and another machine shows nothing at all. 2017 年 3 月 1 日更新:一台机器不工作并产生上述错误,另一台机器什么也没显示。 Clutching at straws about this issue here.在这里紧紧抓住这个问题。

If I tick the box 'Run whether user is logged on or off' The task is invisible.如果我勾选“运行用户是否登录”框,则该任务是不可见的。 We can't do this.我们不能这样做。 Any other suggestions are welcome!欢迎任何其他建议!

Update 2017-03-02: Ticking 'Run whether user is logged on or off' is causing no end of issues. 2017 年 3 月 2 日更新:勾选“无论用户是否登录都运行”会导致问题无休止。 None of our Access macros run anymore, and other 3rd party applications called from the batch don't work with numerous permission errors.我们的 Access 宏不再运行,并且从批处理中调用的其他 3rd 方应用程序无法正常工作,并出现大量权限错误。 This is not the solution!这不是解决方案!

This can occur if the task trigger was set to run One Time when created.如果任务触发器在创建时设置为运行一次,则可能会发生这种情况。 It is possible to set a task to "Run as soon as possible after a scheduled start is missed".可以将任务设置为“错过预定开始后尽快运行”。 This will cause the task to re-run after a reboot if the trigger was missed.如果错过触发器,这将导致任务在重新启动后重新运行。 However, this does not occur if the task is set to run One Time.但是,如果任务设置为一次性运行,则不会发生这种情况。 This behaviour is by design.此行为是设计使然。

You can work around this issue by setting a time and date under the Expire option of the task.您可以通过在任务的过期选项下设置时间和日期来解决此问题。 This option can be reached by opening the Properties of the task, selecting the Triggers tab, and then clicking the Edit button for the trigger in question.可以通过打开任务的属性,选择触发器选项卡,然后单击相关触发器的编辑按钮来访问此选项。 If a date and time are set for the Expire option, the task will attempt to refire on reboot if its previous trigger time was missed.如果为 Expire 选项设置了日期和时间,如果错过了之前的触发时间,任务将在重新启动时尝试重新启动。

I suggest you to set the trigger to "At startup".我建议您将触发器设置为“启动时”。 After you rebooted the machine, the task should then be in the "Queued" status.重新启动计算机后,该任务应处于“排队”状态。 This means it will run at the configured interval.这意味着它将以配置的时间间隔运行。

根据您的错误代码,您可以使用此方法来处理您的错误。

对我来说,我必须将«for a duration of..»更改为«Indefinitely»,并且必须将«Daily»更改为«One time»

This issue got resolved by updating 2 options in tasks.此问题已通过更新任务中的 2 个选项得到解决。

  1. Set task to “Run as soon as possible after a scheduled start is missed” in the settings tab.在设置选项卡中将任务设置为“错过预定开始后尽快运行”。
  2. Set expiry for task in trigger tab在触发器选项卡中设置任务的到期时间

But if you have multiple jobs like us.但是,如果您像我们一样有多个工作。 updating every job manually is an tedious work.手动更新每个作业是一项繁琐的工作。

This PowerShell script will help you with that.这个PowerShell 脚本将帮助您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM