win32servicedemo.py 579 B

1234567891011121314151617181920212223
  1. import win32service
  2. import win32con
  3. def EnumServices():
  4. resume = 0
  5. accessSCM = win32con.GENERIC_READ
  6. accessSrv = win32service.SC_MANAGER_ALL_ACCESS
  7. #Open Service Control Manager
  8. hscm = win32service.OpenSCManager(None, None, accessSCM)
  9. #Enumerate Service Control Manager DB
  10. typeFilter = win32service.SERVICE_WIN32
  11. stateFilter = win32service.SERVICE_STATE_ALL
  12. statuses = win32service.EnumServicesStatus(hscm, typeFilter, stateFilter)
  13. for (short_name, desc, status) in statuses:
  14. print(short_name, desc, status)
  15. EnumServices()