我是靠谱客的博主 高大爆米花,最近开发中收集的这篇文章主要介绍windows服务失败选项的命令处理,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述




对于服务失败的处理命令:

sc [<ServerName>] failure [<ServiceName>] [reset= <ErrorFreePeriod>] [reboot= <BroadcastMessage>] [command= <CommandLine>] [actions= {"" | {[run/<MS>] | [restart/<MS>] | [reboot/<MS>]}[/...]]


 

ParameterDescription

<ServerName>

Specifies the name of the remote server on which the service is located. The name must use the Universal Naming Convention (UNC) format (for example, \myserver). To run SC.exe locally, omit this parameter.

<ServiceName>

Specifies the service name returned by the getkeyname operation.

reset= <ErrorFreePeriod>

Specifies the length of the period (in seconds) with no failures after which the failure count should be reset to 0 (zero). Note that this parameter requires the actions= parameter.

reboot= <BroadcastMessage>

Specifies the message to be broadcast when a service fails.

command= <CommandLine>

Specifies the command-line command to be run when the specified service fails. For more information about how to run a batch or VBS file on failure.

actions= {"" | {[run/<MS>] | [restart/<MS>] | [reboot/<MS>]}[/...]

Specifies one or more failure actions and their delay times (in milliseconds), separated by a forward slash (/). Valid actions are run, restart, and reboot. If more than one action is specified, each action must be separated by a forward slash. Use actions= "" to take no action a service fails. Note that this parameter requires the reset= parameter.

/?

Displays help at the command prompt.

command remark      


  • Not all services allow changes to their failure options. Some run as part of a service set.

  • To run a batch file when a service fails, specify command=Cmd.exeDrive:FileName.bat, where Drive:FileName.bat is the fully qualified name of the batch file.

  • To run a VBS file when a service fails, specify command=CscriptDrive:MyScript.vbs, where Drive:MyScript.vbs is the fully qualified name of the script file.

  • You can specify up to three separate actions with the actions= parameter, to be used the first, second, and third times that a service fails.

  • For each command-line option (parameter), the equal sign is part of the option name.

  • A space is required between an option and its value (for example, actions= restart). If the space is omitted, the operation will fail.

sc failure msftpsvc reset= 30 actions= restart/5000
sc failure dfs reset= 60 command= c:windowsservicesrestart_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

最后

以上就是高大爆米花为你收集整理的windows服务失败选项的命令处理的全部内容,希望文章能够帮你解决windows服务失败选项的命令处理所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(38)

评论列表共有 0 条评论

立即
投稿
返回
顶部