Multiple instances of NTService process [modified]
-
Just when I thought all the coding is done, i've hit a brick wall .. It's CP to the rescue :) I have an NT Service ("Windows Service") which does some processing based on a configuration file. I can install and uninstall this NT service using installutil without any problem. However, I need to be able to run multiple instances of the same NT Service each with various param. E.g.
service1.exe /config1.xml
service1.exe /config2.xml
service1.exe /config3.xmlI have tried modifying the install-script and pass param: e.g.
installutil /i "service1.exe /config1.xml"
This installs, but when I look at the actual registry value under HKLM\System\CurrentControlSet\Services\Service1, the "ImagePath" key does not contain the additional arg I passed at install-time. Then I manually modified the registry-key to include the additional arg, but I still cannot run subsequent installutil. It fails with "The specified service already exists" error. How can I install multiple process instances of this Windows NT Service ? (Windows does runs multiple instances of "svchost.exe" without any problem) Due to some constraints I cannot a) consolidate the logic and run as single process multiple threads or b) consolidate the logic and run as single process multiple app-domains or c) create multiple copies of the binaries in N different locations. I look forward to your responses. - Malharmodified on Tuesday, June 3, 2008 5:16 PM
-
Just when I thought all the coding is done, i've hit a brick wall .. It's CP to the rescue :) I have an NT Service ("Windows Service") which does some processing based on a configuration file. I can install and uninstall this NT service using installutil without any problem. However, I need to be able to run multiple instances of the same NT Service each with various param. E.g.
service1.exe /config1.xml
service1.exe /config2.xml
service1.exe /config3.xmlI have tried modifying the install-script and pass param: e.g.
installutil /i "service1.exe /config1.xml"
This installs, but when I look at the actual registry value under HKLM\System\CurrentControlSet\Services\Service1, the "ImagePath" key does not contain the additional arg I passed at install-time. Then I manually modified the registry-key to include the additional arg, but I still cannot run subsequent installutil. It fails with "The specified service already exists" error. How can I install multiple process instances of this Windows NT Service ? (Windows does runs multiple instances of "svchost.exe" without any problem) Due to some constraints I cannot a) consolidate the logic and run as single process multiple threads or b) consolidate the logic and run as single process multiple app-domains or c) create multiple copies of the binaries in N different locations. I look forward to your responses. - Malharmodified on Tuesday, June 3, 2008 5:16 PM
You can have multiple instances but you need to create them as different named services. You have to give them different names. When starting a service, the Service Control Manager looks at the ImagePath to determine if the process that runs this service is already running. If it is but the process specifies WIN32_OWN_PROCESS in the Type value (either for the process already running or the one to be started) it fails. When performing the check, the whole command line, not just the EXE name, is used. SvcHost uses the -k parameter for this purpose. This parameter doesn't do anything. It's just there to make the SCM instruct the right instance of SvcHost to start this service. SvcHost itself is a generic host process - it doesn't do anything itself, it just loads the DLL specified under the service's Parameters key. Microsoft have not documented the interface that a DLL must implement to be loaded by SvcHost - it's intended for their own use only.
DoEvents: Generating unexpected recursion since 1991
-
You can have multiple instances but you need to create them as different named services. You have to give them different names. When starting a service, the Service Control Manager looks at the ImagePath to determine if the process that runs this service is already running. If it is but the process specifies WIN32_OWN_PROCESS in the Type value (either for the process already running or the one to be started) it fails. When performing the check, the whole command line, not just the EXE name, is used. SvcHost uses the -k parameter for this purpose. This parameter doesn't do anything. It's just there to make the SCM instruct the right instance of SvcHost to start this service. SvcHost itself is a generic host process - it doesn't do anything itself, it just loads the DLL specified under the service's Parameters key. Microsoft have not documented the interface that a DLL must implement to be loaded by SvcHost - it's intended for their own use only.
DoEvents: Generating unexpected recursion since 1991