请教下python 获取系统服务状态的方法
时间:2011-10-20
来源:互联网
请教下python 获取系统服务状态的方法?
作者: mouseweiwei 发布时间: 2011-10-20
Python code
运行输出:
D:\test\epp>c:\python27\python 20111020a.py
Application Experience Manual Stopped
Application Layer Gateway Service Manual Stopped
Application Identity Manual Stopped
Application Information Manual Stopped
Apple Mobile Device Manual Stopped
Application Management Manual Stopped
ASP.NET State Service Manual Stopped
Windows Audio Endpoint Builder Auto Running
Windows Audio Auto Running
......
需要安装wmi模块,这个模块又需要安装pywin模块。
def listservices(): import wmi c = wmi.WMI() for service in c.Win32_Service(): print service.Caption,service.StartMode,service.State if __name__=='__main__': listservices()
运行输出:
D:\test\epp>c:\python27\python 20111020a.py
Application Experience Manual Stopped
Application Layer Gateway Service Manual Stopped
Application Identity Manual Stopped
Application Information Manual Stopped
Apple Mobile Device Manual Stopped
Application Management Manual Stopped
ASP.NET State Service Manual Stopped
Windows Audio Endpoint Builder Auto Running
Windows Audio Auto Running
......
需要安装wmi模块,这个模块又需要安装pywin模块。
作者: panzifei 发布时间: 2011-10-20
360主动防御服务有中文,如果你保存为utf8格式,这样一下显示中文服务名出来:
print service.Caption.encode('gbk'),service.StartMode,service.State
print service.Caption.encode('gbk'),service.StartMode,service.State
作者: panzifei 发布时间: 2011-10-20
感谢 帮助 我试试你这个方法
我刚才自己想了个很呆的方法
os.system("sc query Messanger |findstr RUNNING")
用DOS 去判断某些服务是不是开了。。
感觉这么做很不正统
对PY的类库很不熟悉 额
我刚才自己想了个很呆的方法
os.system("sc query Messanger |findstr RUNNING")
用DOS 去判断某些服务是不是开了。。
感觉这么做很不正统
对PY的类库很不熟悉 额
作者: mouseweiwei 发布时间: 2011-10-20
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28