Service Control

Mark Hammond mhammond at
Thu Jan 30 22:43:14 CET 2003

Gerhard Häring wrote:
> Hutchins, Mike <mhutchins at> wrote:
>>I am not trying to be rude, but did I post this to the wrong list?
> Maybe just nobody knew an answer, or all three people who do Windows services
> in Python are on vacation ;-)
>>If I posted to the wrong list, can someone suggest an alternative list
>>for a newbie like myself?
> You've chosen an appropriate list, as this one is about *all* things Python.
> There is, however, a python-win32 specially targeted at the win32 topic:
> Perhaps you'll have better luck there.
> It's also always a good idea to post minimal code that shows the problem. And
> maybe chose a subject that will make Mark Hammond look at your message ;-)

I did ;)  But there wasnt enough information, so I was hoping someone 
else had the time and patience to extract the real problem.

The original problem:
 > I can't seem to be able to control services using win32serviceutil.
 > I keep getting
 > api_error: (1062, 'ControlService', 'The service has not been
 > started.')

It could possibly be because the service has not been started <wink>.

Eg, from Pythonwin:
 >>> win32serviceutil.StopService("Telnet")
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
   File "E:\src\pythonex\win32\Lib\", line 336, in 
     return ControlService(serviceName, 
win32service.SERVICE_CONTROL_STOP, machine)
   File "E:\src\pythonex\win32\Lib\", line 258, in 
     status = win32service.ControlService(hs, code)
error: (1062, 'ControlService', 'The service has not been started.')

Indeed, the service has not been started - so let's start it!
 >>> win32serviceutil.StartService("Telnet")

Now it will stop correctly.

 >>> win32serviceutil.StopService("Telnet")
(16, 3, 3, 0, 0, 0, 0)


More information about the Python-list mailing list