Service Control

Mark Hammond mhammond at skippinet.com.au
Thu Jan 30 16:43:14 EST 2003


Gerhard Häring wrote:
> Hutchins, Mike <mhutchins at amr-corp.com> 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:
> http://mail.python.org/mailman/listinfo/python-win32 
> 
> 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\win32serviceutil.py", line 336, in 
StopService
     return ControlService(serviceName, 
win32service.SERVICE_CONTROL_STOP, machine)
   File "E:\src\pythonex\win32\Lib\win32serviceutil.py", line 258, in 
ControlService
     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)
 >>>

Mark.





More information about the Python-list mailing list