作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想查看服务的sc failure
当前设置。这可能吗?
背景:
我正在使用 Saltstack 为服务设置状态配置。现在,设置服务后,将运行命令行来设置故障行为,例如:
sc failure serviceName reset= 30 actions= restart/5000
我希望能够查询传递给 sc failure
的参数的当前值,以便 Salt 可以验证是否需要进行任何更改,并在推送时记录值的更改出一个新的配置。
从sc failure
和sc query
的文档中,我没有看到任何支持这一点的内容。
在注册表中,在 HKLM:\SYSTEM\CurrentControlSet\services\myService\
处,有一个键 FailureActions
。但我不知道如何读取此键的值以将其与我想要的状态进行比较:
PS C:\Users\blaffoy> (Get-ItemProperty -path $key -name failureactions).failureactions
30
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
20
0
0
0
1
0
0
0
136
19
0
0
一些实验表明第一个数字对应于 reset
参数,但除此之外我不知道如何协调其余的输出。
最佳答案
sc.exe 是 Windows 服务 API 的命令行界面。 QueryServiceConfig2
处理多种查询类型,这些查询类型公开为以下命令:
qdescription
qfailure
qfailureflag
qsidtype
qprivs
qtriggerinfo
您需要的命令是 sc [server] qfailure <service name> <bufferSize>
.
关于Windows 服务 Controller : view `sc failure` settings for a service,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28807903/
我是一名优秀的程序员,十分优秀!