Проекты

SAL Host Windows Service

This host is well suited for modules that do not require user interaction but need to be constantly running. For example it can be some applications that tracking banking transactions, system monitoring, launching some logic without user interaction, ServiceBus, post-processing, Telegram bot etc.

This host can be installed from command line and it's using Win32 API functions from advapi32.dll library.

By default all tracing logs will be stored in file: C:\log\Flatbed.WinService.log therefore, if you want to see the logs, you need to create this folder on the file system, and if you want to change the behavior of the trace component, you need to edit the section <system.diagnostics> in Flatbed.WinService.exe.config file.

Starting from version 1.0.7142.31597 the key Switch.System.Net.DontEnableSystemDefaultTlsVersions is added to .config file, therefore, the transport encryption settings are taken from the registry, and not from .NET configuration.

Warning

Before launching executable don't forget to add /? key for a list of possible commands. By default when launching service without arguments (list follows), host will launched as console application, will try to load all plugins and started not as a service but as console application. This is done to check is necessary for integration testings to simplify check how all loaded plugins are interacted with each other.

Arguments

Primary arguments to interact with host before launching:

  • /Install (/I) — Install service (additional keys see below)
  • /Uninstall (/U) — Uninstall service (additional keys see below)
  • /Help (/?) — Get help of all commands. (Help renders from attributes, so some formatting might not be pretty)
  • /Debug — Launch service from command line. Convenient to debug plugins.

Additional arguments

This arguments are used to customize service in install and uninstall time

  • /ServiceName:{SALFlatbedSvc} (/N:{SALFlatbedSvc}) — Specify service name (Used in install and uninstall time)
  • /DisplayName:{SAL Flatbed Service} (/D:{SAL Flatbed Service}) — Specify service display name
  • /Arguments:{null} (/A:{null}) — Arguments that will be available when starting the service via System.Environment.GetCommandLineArgs().
  • /Acess:{AllAccess} (/R:{AllAccess}) — Service access level. Available values (String value is used):
    • QueryConfig (0x0001) — Required to call the QueryServiceConfig and QueryServiceConfig2 functions to query the service configuration.
    • ChangeConfig (0x0002) — Required to call the ChangeServiceConfig or ChangeServiceConfig2 function to change the service configuration. Because this grants the caller the right to change the executable file that the system runs, it should be granted only to administrators
    • QueryStatus (0x0004) — Required to call the QueryServiceStatus or QueryServiceStatusEx function to ask the service control manager about the status of the service. Required to call the NotifyServiceStatusChange function to receive notification when a service changes status
    • EnumerateDependencies (0x0008) — Required to call the EnumDependentServices function to enumerate all the services dependent on the service
    • Start (0x0010) — Required to call the StartService function to start the service
    • Stop (0x0020) — Required to call the ControlService function to stop the service
    • PauseContinue (0x0040) — Required to call the ControlService function to pause or continue the service
    • Interrogate (0x0080) — Required to call the ControlService function to ask the service to report its status immediately
    • UserDefinedControl (0x0100) — Required to call the ControlService function to specify a user-defined control code
    • StandartRightsRequired (0xF0000)
    • AllAccess — All of the above
  • /Type:{Win32OwnProcess} (/T:{Win32OwnProcess}) — Service type. Available values (String values is used):
    • KernelDriver (0x00000001) — Driver service
    • FileSystemDriver (0x00000002) — File system driver service
    • Adapter (0x00000004) — Reserved
    • RecognizerDriver (0x00000008) — Reserved
    • Win32OwnProcess (0x00000010) — Service that runs in its own process
    • Win32ShareProcess (0x00000020) — Service that shares a process with one or more other services
    • InteractiveProcess (0x00000100) — The service can interact with the desktop
  • /Start:{BootStart} (/S:{BootStart}) — Service launch rules. Available values (String value is used):
    • BootStart (0x00000000) — A device driver started by the system loader. This value is valid only for driver services
    • SystemStart (0x00000001) — A device driver started by the IoInitSystem function. This value is valid only for driver services
    • AutoStart (0x00000002) — A service started automatically by the service control manager during system startup. For more information, see Automatically Starting Services
    • DemandStart (0x00000003) — A service started by the service control manager when a process calls the StartService function. For more information, see Starting Services on Demand
    • Disabled (0x00000004) — A service that cannot be started. Attempts to start the service result in the error code ERROR_SERVICE_DISABLED
  • /Error:{Normal} (/E:{Normal}) — Service behavior when error is occurred in the launch time. Available values (String values is used):
    • Ignore (0x00000000) — The startup program ignores the error and continues the startup operation
    • Normal (0x00000001) — The startup program logs the error in the event log but continues the startup operation
    • Severe (0x00000002) — The startup program logs the error in the event log. If the last-known-good configuration is being started, the startup operation continues. Otherwise, the system is restarted with the last-known-good configuration.
    • Critical (0x00000003) — The startup program logs the error in the event log, if possible. If the last-known-good configuration is being started, the startup operation fails. Otherwise, the system is restarted with the last-known good configuration.
  • /Dependencies:{null} — A list of system names of services, separated by commas, that must be started before starting this service.
  • /Login:{NT AUTHORITY\NetworkService} (/L:{NT AUTHORITY\NetworkService}) — User that is used to run current service as
  • /Password:{null} (/P:{null}) — The password under which the service will be launched. For the NetworkService account of the current machine, no password is required

In total, of all the parameters, only lpdwTagId & lpLoadOrderGroup are missed (See CreateService). Unfortunately I don't find any appliance that's why I dont know where to inmplement & test them. If you got good example where those arguments are used I can implement them.

Теги:

Скачать

Ссылки

Родительские файлы

Дочерние файлы