Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Multiple instances of NTService process [modified]

Multiple instances of NTService process [modified]

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestionwindows-admintoolsxml
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    malharone
    wrote on last edited by
    #1

    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.xml

    I 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. - Malhar

    modified on Tuesday, June 3, 2008 5:16 PM

    M 1 Reply Last reply
    0
    • M malharone

      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.xml

      I 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. - Malhar

      modified on Tuesday, June 3, 2008 5:16 PM

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • M Mike Dimmick

        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

        M Offline
        M Offline
        malharone
        wrote on last edited by
        #3

        Yup.. there was a great startup article .. this solved the problem! http://osdir.com/ml/windows.devel.dotnet.general/2002-05/msg00446.html[^] - MS

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups