listing existing windows services with python

alex23 wuwei23 at
Tue Feb 16 03:16:19 CET 2010

News123 <news... at> wrote:
> What is the best way with python to get a list of all windows services.
> As a start I would be glad to receive only the service names.
> However it would be nicer if I could get all the properties of a service
> as well.

I highly recommend Tim Golden's fantastic WMI module[1].

    >>> import wmi
    >>> c = wmi.WMI()
    >>> services = c.Win32_Service()
    >>> s = services[0]
    >>> s
    <_wmi_object: \\LIB-D5NYF1S\root
    {u'DisplayName': None, u'ServiceSpecificExitCode': None, u'State':
None, u'Syste
    mName': None, u'ErrorControl': None, u'Status': None,
u'ProcessId': None, u'Desc
    ription': None, u'Started': None, u'AcceptStop': None,
u'CheckPoint': None, u'Pa
    thName': None, u'WaitHint': None, u'Name': None, u'InstallDate':
None, u'Caption
    ': None, u'StartMode': None, u'DesktopInteract': None,
u'ServiceType': None, u'T
    agId': None, u'StartName': None, u'AcceptPause': None,
u'CreationClassName': Non
    e, u'SystemCreationClassName': None, u'ExitCode': None}
    >>> s.Name
    >>> s.Started
    >>> s.ServiceType
    u'Share Process'


More information about the Python-list mailing list