指定服务失败时要采取的操作。
sc [ServerName] failure [ServiceName] [reset= ErrorFreePeriod] [reboot= BroadcastMessage] [command= CommandLine] [actions= FailureActionsAndDelayTime]
指定服务所在的远程服务器名称。该名称必须使用 UNC 格式 ("\\myserver")。若要在本机上运行 SC.exe,请忽略此参数。
指定由 getkeyname 操作返回的服务名。
指定没有失败的周期长度(单位为秒),此后失败计算器的应该重置为 0。这个参数必须与 actions= 参数结合使用。
指定服务失败时要广播的消息。
指定服务失败时要运行的命令行。有关在失败时如何运行批处理或 VBS 文件的信息,请参阅“注释”。
指定失败操作及其延迟时间(单位为毫秒),以正斜杠 (/) 隔开。下列操作有效:run、restart 和 reboot。此参数必须与 reset= 参数结合使用。在失败时不采取操作请使用 actions= ""。
在命令提示符显示帮助。
不是所有的服务都允许更改其失败选项。其中一些作为服务集的一部分运行。
要在失败时运行批处理文件,请指定 cmd.exe Drive:\FileName.bat 为 command= 的参数,其中 Drive:\FileName.bat 是批处理文件的完整的合格名称。
要在失败时运行 VBS 文件,请指定 cscript drive:\myscript.vbs 为 command= 的参数,其中 drive:\myscript.vbs 是脚本文件的完整的合格名称。
可以将三种不同的操作指定为 actions= 的参数,它们将会在服务的第一次、第二次、第三次失败时使用。
如果参数及其值之间没有空格,(例如,是 type= own,而不是 type=own),则操作会失败。
下面的范例显示了如何使用 sc failure 命令:
sc failure msftpsvc reset= 30 actions= restart/5000 sc failure dfs reset= 60 command= c:\windows\services\restart_dfs.exe actions= run/5000 sc failure dfs reset= 60 actions= reboot/30000 sc failure dfs reset= 60 reboot= "The Distributed File System service has failed. Because of this, the computer will reboot in 30 seconds." actions= reboot/30000 sc failure myservice reset= 3600 reboot= "MyService crashed -- rebooting machine" command= "%windir%\MyServiceRecovery.exe" actions= restart/5000/run/10000/reboot/60000
未完见下页