Multiple windows services on the same machine

M

Massi

Hi everyone, I'm writing a script which implement a windows service
with the win32serviceutil module. The service works perfectly, but now
I would need to install several instances of the same service on my
machine for testing purpose.
This is hard since the service name is hard-coded in the service class
definition:

class MyService(win32serviceutil.ServiceFramework) :
_svc_name_ = 'MyService'
_svc_display_name_ = 'Instance ofMyService'

def __init__(self, args) :
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

def SvcStop(self) :
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
sys.stopservice = "true"
win32event.SetEvent(self.hWaitStop)

def SvcDoRun(self) :
#Do something...

So can anyone point me out which is the best way to "parametrize" the
service name? Thanks in advance for your help!
 
M

Mark Hammond

Hi everyone, I'm writing a script which implement a windows service
with the win32serviceutil module. The service works perfectly, but now
I would need to install several instances of the same service on my
machine for testing purpose.
This is hard since the service name is hard-coded in the service class
definition:

class MyService(win32serviceutil.ServiceFramework) :
_svc_name_ = 'MyService'
_svc_display_name_ = 'Instance ofMyService'

It is only hard-coded in the HandleCommandLine function - you probably
just want your own argv parsing and call InstallService directly.

HTH,

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top