Windows Services Recovery option doesn't work ... or I don't understand it RRS feed

Posted Chuck Lu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Windows Services Recovery option doesn't work ... or I don't understand it RRS feed相关的知识,希望对你有一定的参考价值。

Windows Services Recovery option doesn\'t work ... or I don\'t understand it

You could have a look at the blog post below, see if it helps you!

https://blogs.msdn.microsoft.com/jcalev/2008/01/10/some-tricks-with-service-restart-logic/

" First failure: what should occur the first time the service fails.  Valid options are "Take No Action", "Restart the Service", "Run a Program", and "Restart the Computer".


Second failure: same options the second time a service fails


Subsequent failures: same options for any subsequent failure


Reset fail count after: the number of days the service must be running before the failure count is reset


Restart service after: the amount of time in minutes to wait to restart the service


This is very nice, but it is very easy to misunderstand what these values actually do.  I have seen a number of services (and I tried this myself) set these values to 0 days and 0 minutes.  The problem is your service will continually restart if you set the failure count to reset after 0 days, if the service at least started correctly.  The result is only the first option ("first failure") will ever be run. 


To fix this, set the failure count to reset after one day.  The drawback to this approach is your service may stay stopped after failing several times but this likely means something is toast anyways.


One thing also to take into account is not all services will work with the reset logic - or in other words just setting the recovery options on any service does not guarantee that it will restart.  In order for the service to restart, it must exit abnormally.  This generally means the service must exist with a non-zero exit code and the service status must not be stopped (note: this has changed for Vista - it is possible to set the service status to stopped and provide an exit code to trigger the restart logic).

 

 

Best regards,
Leon

 

How can I automatically restart a Windows service if it crashes?

I have a Windows service that exits unexpectedly every few days. Is there a simple way to monitor it to make sure it gets restarted quickly if it crashes?

 

回答

Under the Services application, select the properties of the service in question.

View the recovery tab - there are all sorts of options - I\'d set First & Second Failure to Restart the Service, Third to run a batch program that BLAT\'s out an email with the third failure notification.

You should also set the Reset Fail Count to 1 to reset the fail count daily.

EDIT:

Looks like you can do this via a command line:

SC failure w3svc reset= 432000  actions= restart/30000/restart/60000/run/60000
SC failure w3svc command= "MyBatchFile.cmd"

Your MyBatchFile.CMD file can look like this:

blat - -body "Service W3svc Failed" -subject "SERVICE ERROR" -to Notify@Example.com -server SMTP.Example.com -f Administrator@Example.com

 

What is Blat?
Blat is a Windows (32 & 64 bit) command line utility that sends eMail using SMTP or post to usenet using NNTP. 

 

 

Trying to set services to restart ANYTIME they fail. I need this setting to NEVER Expire?

回答1

The reset failure count is the "trigger" for the second recovery action. IF its is set to 0 it will never trigger the second condiction.

 

回答2

Setting "Reset fail count after" to 0 means "reset the fail count to 0 after each failure" until a reboot occurs.

The 0 effectively disables both, the "second failure" and "subsequent failure" actions and you will always get the "first failure" action, until you reboot the machine.

 

 

 

 

Microsoft windows XP Recovery Console是啥啊?

Microsoft windows XP Recovery Console是什么啊?在开电脑时上面一个是XP家庭版,从前都只是有一个啊,我从来没装过Microsoft windows XP Recovery Console这种系统啊,会不会影响系统啊?这个是什么有谁能告诉我啊?谢了!!
那这个"微软WIN XP恢复控制台"是好的还是坏的?他有什么用处发?谢谢~!

翻译为“微软WIN XP恢复控制台”

如需将Recovery Console(恢复控制台)作为系统启动选项加以安装, 请依次执行下列操作步骤:

在Windows XP处于运行状态的情况下, 将Windows XP光盘插入驱动器, 并在安装选项出现时单击Exit(退出)。
依次单击Start(开始)和Run(运行), 并在随后出现的Run(运行)对话框内输入D:/i386/winnt32.exe /cmdcons(D:在这里指代光驱盘符), 并按下Enter(回车)键。(请务必在.exe扩展名和正斜杠之间插入一个空格)
依照屏幕提示信息安装Recovery Console(恢复控制台), 并在安装操作完成后重新启动您的计算机。
Recovery Console(恢复控制台)将作为可供选择的操作系统项目出现在Startup(启动)菜单中。如需对Recovery Console(恢复控制台)加以使用, 则必须具备管理员权限。
如果i386目录已被安装于您的计算机(在已预装有Windows XP操作系统的计算机上通常如此), 您将可使用与第二步完全相同的语法, 并在无须借助安装光盘的前提下选择使用[path]/i386目录。

另一种替代方法是利用光盘引导计算机, 并启动WINNT.EXE文件, 当系统提示用户选择Install(安装)或Repair(修复)时, 单击Repair(修复), 以便将Recovery Console(恢复控制台)安装在您的计算机上。

如果Windows XP并未启动, 则可从安装光盘上运行Recovery Console(恢复控制台)。

参考资料:http://www.microsoft.com/china/windowsxp/expertzone/tips/february/vinson1.asp

参考技术A 这个恢复控制台用处大着呢!

如果你按照楼上的方法将它装到硬盘上,就可以在系统崩溃的时候进去格式化磁盘呀、提取系统文件呀、修复系统呀等等。不过全部是命令行,要用要打一大堆命令,很麻烦的。

可是现在知道了有Win PE这么一样好东西,就不用恢复控制台了。
关于Win PE,看这里:
http://baike.baidu.com/view/759779.htm

以上是关于Windows Services Recovery option doesn't work ... or I don't understand it RRS feed的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 Symantec Recovery Disk 异机还原 Windows 7

Microsoft windows XP Recovery Console是啥啊?

求助fedora 21如何进入recovery

Win10专业版找不到Recovery Environment

DB处于Recovery Pending状态

Android之Recovery业务(三)-update.zip制作