469,360 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

How can I enumerate all windows services and disable some of them?

I know that Module win32service has some functions on manipulating
win32 services.
But I still have 2 questions:
1. how to enumerate all services?
2. how to disable a certain one?

Thanks in advance!

Aug 22 '06 #1
1 1965

<co*******@gmail.comwrote in message news:11**********************@m73g2000cwd.googlegr oups.com...
>I know that Module win32service has some functions on manipulating
win32 services.
But I still have 2 questions:
1. how to enumerate all services?
2. how to disable a certain one?

Thanks in advance!
win32service.EnumServicesStatus lists services, and ChangeServiceConfig
lets you change the start type to disabled.

import win32service
hscm=win32service.OpenSCManager(None,None,win32ser vice.SC_MANAGER_ALL_ACCESS)
svcs=win32service.EnumServicesStatus(hscm)
for svc in svcs:
if svc[0]=='PyPipeTestService':
hsvc=win32service.OpenService(hscm, svc[0], win32service.SERVICE_CHANGE_CONFIG)
win32service.ChangeServiceConfig(hsvc, win32service.SERVICE_NO_CHANGE,
win32service.SERVICE_DISABLED, win32service.SERVICE_NO_CHANGE, None, None,0,
None,None,None,None)
win32service.CloseServiceHandle(hsvc)
win32service.CloseServiceHandle(hscm)
Roger

Aug 22 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by =?Utf-8?B?TWljaGFlbCAwMw==?= | last post: by
3 posts views Thread by netzorro | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.