How to operate windows system services in Python
怪我咯
怪我咯 2017-06-22 11:51:20
0
1
782
def listservices():
    import wmi
    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()

How to change the startup type and status?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
滿天的星座

There are examples in the module author’s documentation

http://timgolden.me.uk/python...

import wmi
c = wmi.WMI()
for service in c.Win32_Service(Name="seclogon"):
  result, = service.StopService()
  if result == 0:
    print "Service", service.Name, "stopped"
  else:
    print "Some problem"
  break
else:
  print "Service not found"
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template