Stop/Start Service in Win2k
Syver Enstad
syver at NOSPAMcyberwatcher.com
Thu Jun 21 21:10:58 EDT 2001
Have you tried to test the names by using net start/stop on the command
line? It looks as you've got the wrong names to me.
"Robin Siebler" <rsiebler at ibeam.com> wrote in message
news:%4vY6.9705$Up.285700 at sea-read.news.verio.net...
> I got a script off the ActiveState site that will stop and start a service
> (the script is at the bottom of this post) . It works fine on NT4 and it
> works for some services on Win2k, but for most services, I get the below
> error:
>
>
> Traceback (most recent call last):
> File "<interactive input>", line 1, in ?
> File "c:\python21\scripts\winsvc.py", line 37, in service_info
> if win32serviceutil.QueryServiceStatus(service, machine)[1] == 4:
> File "c:\python21\win32\lib\win32serviceutil.py", line 359, in
> QueryServiceStatus
> hs = win32service.OpenService(hscm, serviceName,
> win32service.SERVICE_QUERY_STATUS)
> api_error: (1060, 'OpenService', 'The specified service does not exist as
an
> installed service.')
>
>
> Could someone tell me why this happens and how to fix it?
>
> Thanks!
>
> import win32serviceutil
>
> def service_info(action, machine, service):
> if action == 'stop':
> win32serviceutil.StopService(service, machine)
> print '%s stopped successfully' % service
> elif action == 'start':
> win32serviceutil.StartService(service, machine)
> print '%s started successfully' % service
> elif action == 'restart':
> win32serviceutil.RestartService(service, machine)
> print '%s restarted successfully' % service
> elif action == 'status':
> if win32serviceutil.QueryServiceStatus(service, machine)[1] == 4:
> print "%s is running normally" % service
> else:
> print "%s is *not* running" % service
>
> if __name__ == '__main__':
> machine = 'cr582427-a'
> service = 'Zope23'
> action = 'start'
> service_info(action, machine, service)
>
>
>
>
More information about the Python-list
mailing list