Starting Win32 Service
Tim Golden
tim.golden at viacom-outdoor.co.uk
Wed Sep 27 04:06:43 EDT 2006
[placid]
| Using Tim Golden's wmi module you can get the service names
|
| import wmi
| c = wmi.WMI ()
| stopped_services = c.Win32_Service (StartMode="Auto", State="Stopped")
| if stopped_services:
| for s in stopped_services:
| print s.Caption, "service is not running"
| else:
| print "No auto services stopped"
|
| but how do i start services that are stopped?
<code>
import wmi
c = wmi.WMI ()
for method in c.Win32_Service._methods:
print method
#
#... includes StartService
#
print c.Win32_Service.StartService
# <function StartService () => (ReturnValue)>
#
# Therefore, to start all non-running auto services (!)
#
for service in c.Win32_Service (StartMode="Auto", State="Stopped"):
print service.Caption
service.StartService ()
</code>
TJG
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
More information about the Python-list
mailing list