[python-win32] Windows Service Parameters
mhammond at skippinet.com.au
Fri Apr 7 03:26:06 CEST 2006
> 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:
def __init__(self, args):
# use args - args 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)
More information about the Python-win32