找回密码
 加入
搜索
查看: 1541|回复: 11

ServiceControl.au3有问题吗?

[复制链接]
发表于 2009-9-21 13:08:30 | 显示全部楼层 |阅读模式
本帖最后由 menfan 于 2009-9-21 13:42 编辑

#include <ServiceControl.au3>

Dim $nRet

; 开始/停止服务

If _ServiceExists("", "Windows Time") Then
      
   MsgBox(4096,'测试服务' , 'Windows Time 服务存在!')   
   If _ServiceRunning("", "Windows Time") Then
      MsgBox(4096,'测试服务' , 'Windows Time 服务运行')
      If _StopService("", "Windows Time") Then
         MsgBox(4096,'测试服务' , 'Windows Time 服务停止')
      EndIf
   Else
      MsgBox(4096,'测试服务' , 'Windows Time 服务停止')
      If _StartService("", "Windows Time") Then
         MsgBox(4096,'测试服务' , 'Windows Time 服务开始')
      EndIf
   EndIf
Else
   MsgBox(4096,'测试服务' , 'Windows Time服务不存在')   
EndIf

奇怪,是不是ServiceControl.au3有问题呢?
 楼主| 发表于 2009-9-21 13:13:16 | 显示全部楼层
Windows Time服务存在且运行,怎么判断Windows Time服务不存在呢?还有更新后的ServiceControl.au3吗?
发表于 2009-9-21 13:34:18 | 显示全部楼层
"Windows Time" 改成 "W32Time" 即可
 楼主| 发表于 2009-9-21 13:41:18 | 显示全部楼层
上例中的"Windows Time" 改成 "W32Time" 是可以实现,但是为什么用net start查询出来的服务是windows time,而不是W32Time呢?
发表于 2009-9-21 13:44:07 | 显示全部楼层
本帖最后由 afan 于 2009-9-21 14:08 编辑

显示名和服务名是不同的,起作用的是服务名(另,服务名一般没有空格)。
 楼主| 发表于 2009-9-21 13:46:37 | 显示全部楼层
#include <ServiceControl.au3>

Dim $nRet

; 开始/停止服务

If _ServiceExists("", "server") Then
      
   MsgBox(4096,'测试服务' , 'server 服务存在!')   
   If _ServiceRunning("", "server") Then
      MsgBox(4096,'测试服务' , 'server 服务运行')
      If _StopService("", "server") Then
         MsgBox(4096,'测试服务' , 'server 服务停止')
      EndIf
   Else
      MsgBox(4096,'测试服务' , 'server 服务停止')
      If _StartService("", "server") Then
         MsgBox(4096,'测试服务' , 'server 服务开始')
      EndIf
   EndIf
Else
   MsgBox(4096,'测试服务' , 'server服务不存在')   
EndIf

也是一样哦,又是什么服务名呢?通过什么查询到呢?呵呵
发表于 2009-9-21 13:50:40 | 显示全部楼层
LanmanServer
在服务里可以查看
 楼主| 发表于 2009-9-21 13:54:54 | 显示全部楼层
如果不是系统服务,而是程序服务呢?服务名带空格呢?不支持吗?我试过好像是不行的哦
 楼主| 发表于 2009-9-21 13:56:00 | 显示全部楼层
目前我是命令行的形式处理的,但是我还是想通过UDF实现,有没有可以实现支持服务名带空格的UDF呢?
 楼主| 发表于 2009-9-21 13:59:20 | 显示全部楼层
明白,谢了,我找到原因啦:)呵呵
发表于 2009-9-21 14:09:24 | 显示全部楼层
如果服务名有空格就加双引号,不管是批处理还是au3
 楼主| 发表于 2009-9-21 14:26:22 | 显示全部楼层
本帖最后由 menfan 于 2009-9-21 14:27 编辑

没错,受教啦,呵呵(另注:sc query可查服务名)
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-5 03:15 , Processed in 0.076568 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表