[python-win32] Windows Service Parameters

Emlyn Jones emlynj at gmail.com
Fri Apr 7 15:56:29 CEST 2006


On 4/7/06, Mark Hammond <mhammond at skippinet.com.au> wrote:
> > Hello,
> > Does anybody have an example of getting hold of the "start parameters"
> > in a Python windows service?
> > I was half expecting them to be passed to SvcDoRun but I can't see
> > that they are.
>
> Not an example - but they are passed to your service's __init__ function.
> Most of the examples don't show that - so you need:
>
> class MyService(win32serviceutil.ServiceFramework):
>  ...
>   def __init__(self, args):
>     win32serviceutil.ServiceFramework.__init__(self, args)
>     # use args - args[0] is the "service name"
>
> Also note that no one persists these service arguments - so entering them
> into the service manager means they get passed as you start the service that
> once - they will not be passed in the future as the serivce starts normally.
>
> For this reason it is common for your code to write the args to the registry
> so you can see them next time.  win32serviceutil.Set/GetServiceCustomOption
> may help (but obviously you can persist them any way you choose)
>
> Mark
>
>
Hello, thanks for the reply.
Ok. That makes sense. The non persistance will explain why my testing
with args to __init__ didn't show anything. Thanks Mark.

Cheers,
Emlyn.

P.S I mailed to this list a little while ago about some problems with
the debugger and Python/ASP; I am still intending to revist the
"hacks" I made to get it working, I'll drop you a mail detailing them
when I get round to it.


More information about the Python-win32 mailing list