locked
Create Application to register the same windows service multiple times with different startup parameters RRS feed

  • Question

  • User-954539637 posted

    Hi, I am searching for advice on the best way to proceed with installation of multiple services.

    Prelim: I have created an a elaborate service that accepts startup parameters. For example, we may have 10 thousand users, and we want to reuse the same service which will handle a set number of users. For example, one server might handle A-L and another handles M-Z, but we want the administrator to decide how many services and the number of users the service might handle. Want to make this bullet proof, if possible.

    So we are thinking about the following.

    1. We want to create an application that registers the service and startup parameters. (local to the machine - would like to do this in a remote core app, but I do not think this is possible)
    2. We want to store the registration configuration in a database that can be read remotely.
    3. We also want to create a Core web app that starts and stops the services remotely.  (we currently have a Core 2.1 web app that we would like to use)

    Not sure which way to go with # 1. Want to make this very flexible

    Does anybody have any recommendations?

    Thanks, Tom

    Monday, January 7, 2019 7:48 PM

Answers

  • User-943250815 posted

    Of course it depends on your needs but, you can have:
    1) Single Service dealing with group ranges (A-L and M-Z);
    2) One executable loaded as service as many times you need (as the subject)

    Some point should be considered:
    1) Each SERVICE should have a UNIQUE Service Name;
    2) You will need Administrator Rights to Install Service;
    3) To Start/Stop service from a Web App, you should give rights to Web App User on Service;

    To install a Service with Admin Rights you can use, in lines bellow /RANGE=Group_AL is a parameter to be used by Installer of your service
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /RANGE=Group_AL C:\<directory>\<your executable file>
    To uninistall service already installed
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe / u /RANGE=Group_AL C:\<directory>\<your executable file>

    About Unique Name, it is defined in Installer of service, where you can catch "/RANGE=Group_AL", to define Service Name, Description, Display Name and Command line with parameters

    To Start/Stop from a WebApp, we use subinacl.exe:
    Grant Permission: subinacl /service <service name> /grant=<application pool user>=SETO
    Revoke Permission: subinacl /service <service name> /revoke=<application pool user>

    InstallUtil) https://docs.microsoft.com/en-us/dotnet/framework/tools/installutil-exe-installer-tool
    (SubInAcl) https://www.microsoft.com/en-us/download/details.aspx?id=23510

    By the way the is nothing on MS doc that say you can add your own parameter on command line, found it googling on web. It works.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 7, 2019 8:40 PM

All replies

  • User753101303 posted

    Hi,

    Not sure which kind of processing this is. A common design is to queue work and have one or more services taking work from this queue. This way rather than dedicating a service to a range of users (and if unlucky being quite busy while other services are idle) you could just add/remove services as needed.

    Monday, January 7, 2019 8:07 PM
  • User-943250815 posted

    Of course it depends on your needs but, you can have:
    1) Single Service dealing with group ranges (A-L and M-Z);
    2) One executable loaded as service as many times you need (as the subject)

    Some point should be considered:
    1) Each SERVICE should have a UNIQUE Service Name;
    2) You will need Administrator Rights to Install Service;
    3) To Start/Stop service from a Web App, you should give rights to Web App User on Service;

    To install a Service with Admin Rights you can use, in lines bellow /RANGE=Group_AL is a parameter to be used by Installer of your service
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /RANGE=Group_AL C:\<directory>\<your executable file>
    To uninistall service already installed
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe / u /RANGE=Group_AL C:\<directory>\<your executable file>

    About Unique Name, it is defined in Installer of service, where you can catch "/RANGE=Group_AL", to define Service Name, Description, Display Name and Command line with parameters

    To Start/Stop from a WebApp, we use subinacl.exe:
    Grant Permission: subinacl /service <service name> /grant=<application pool user>=SETO
    Revoke Permission: subinacl /service <service name> /revoke=<application pool user>

    InstallUtil) https://docs.microsoft.com/en-us/dotnet/framework/tools/installutil-exe-installer-tool
    (SubInAcl) https://www.microsoft.com/en-us/download/details.aspx?id=23510

    By the way the is nothing on MS doc that say you can add your own parameter on command line, found it googling on web. It works.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 7, 2019 8:40 PM
  • User-954539637 posted

    Thanks for your response. Very helpful.

    Yep years ago I designed services for market data, and I know we created several services with different names and startup parameters. But that was all command line, and I need to design a application that is very user friendly to install and configure the services.

    Thanks for the "subinacl" tip.

    Monday, January 7, 2019 10:41 PM
  • User-943250815 posted

    One last note, for your Start/Stop App, don´t query services like

    ServiceController.GetServices().Any(Function(serviceController) serviceController.ServiceName.Equals(<MySvcName>))

    App Pool user will have permission only on designed service, not all services, so it can not list services

    Tuesday, January 8, 2019 2:02 PM