import wmi
def listservices():
c = wmi.WMI()
for service in c.Win32_Service():
#print(service.Caption,service.StartMode,service.State)
print(service.Caption) #名称
print(service.StartMode) #启动类型
print(service.State) #状态
if name=='main': listservices()
可以获取当前全部的系统服务的名称 启动类型、状态 但是要怎么才可以更改呢?
1
sunhk25 2017-06-22 09:58:58 +08:00
service.ChangeStartMode (StartMode="Automatic")
https://mail.python.org/pipermail/python-list/2003-September/226274.html |
2
linus3389 2017-06-22 09:59:28 +08:00
os.system("net stop/start service_name")
状态可以 sc query service_name |
3
NoAnyLove 2017-06-22 10:21:52 +08:00
|