javascript 停止特定服务
我在脚本中有以下代码。 问题是我想获取以特定名称启动并处于特定启动模式的脚本的信息。
var e = new Enumerator(GetObject("winmgmts:").InstancesOf("Win32_Service"))
var WSHShell = new ActiveXObject ("WScript.Shell");
var strPrefix = "TTTT";
for(;!e.atEnd(); e.moveNext()){
var Service = e.item();
var strName = Service.Name;
if (strName.substr (0, strPrefix.length) == strPrefix) {
if(Service.StartMode == 'mmManual') {
WScript.Echo("Yes");
}
if(e.StartMode == 'Manual') {
WScript.Echo("Yes");
}
}
}
在上面的脚本中,我试图了解启动模式,但它总是返回 true。
I have the following code in a script.
The problem is That I want to get information of scripts that starts in a specific name and are in a specific startmode.
var e = new Enumerator(GetObject("winmgmts:").InstancesOf("Win32_Service"))
var WSHShell = new ActiveXObject ("WScript.Shell");
var strPrefix = "TTTT";
for(;!e.atEnd(); e.moveNext()){
var Service = e.item();
var strName = Service.Name;
if (strName.substr (0, strPrefix.length) == strPrefix) {
if(Service.StartMode == 'mmManual') {
WScript.Echo("Yes");
}
if(e.StartMode == 'Manual') {
WScript.Echo("Yes");
}
}
}
In the above script I tried to know the start mode but it always return true.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
McDowell 是对的,但请注意,如果将前缀和启动模式检查作为 WMI 查询的一部分,则可以在循环中删除它们:
使用此查询,您的脚本可能如下所示:
McDowell is right, but note that you can get rid of prefix and start mode checks in your loop if you make them part of the WMI query:
Using this query, your script could look like this:
我不确定您到底在问什么,但这...
...将始终评估为
true
。您缺少=
。应该是:I'm not sure exactly what you're asking, but this...
...will always evaluate to
true
. You are missing an=
. It should be: