找回密码
 加入
搜索
查看: 1938|回复: 2

[AU3基础] [已解决]Windows 8.1下有些系统服务的自定义函数失效了

[复制链接]
发表于 2014-2-12 23:16:18 | 显示全部楼层 |阅读模式
本帖最后由 smooth 于 2014-2-13 08:57 编辑

今天晚上突然发现,系统服务的自定义函数,在Windows 8.1下有的不能使用,例如:

Func _ServStop($iName, $Computer = ".")
        Local $Service = ObjGet("winmgmts:\\" & $Computer & "\root\cimv2")
        Local $sItems = $Service.ExecQuery("Select * from Win32_Service Where State = 'Running' ")
        For $objService In $sItems
                If $objService.Name == $iName Then
                        If $objService.AcceptStop = 0 Then Return SetError(-2)
                        $objService.StopService($objService.Name)
                        Return
                EndIf
        Next
        Return SetError(-1)
EndFunc   ;==>_ServStop

好像是系统权限的问题。请教AU3如何获取管理员的权限?
 楼主| 发表于 2014-2-12 23:51:43 | 显示全部楼层

@OSversion

也检测不到系统的版本了。。
 楼主| 发表于 2014-2-13 08:56:46 | 显示全部楼层
找到问题的根源了,因为我在Windows 8.1的用户是新建的,不是用Administrator这个用户,所以脚本不能以管理员身份来运行,把#RequireAdmin 代码插入到脚本的开头就好了!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 13:16 , Processed in 0.083355 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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