Run an application as a Windows Service
A Windows Service is an executable application that the operating system runs in the background. It does not require a logged-in user session to run. In Windows, the Service Control Manager (SCM) manages all Windows service processes. The SCM is a special system process that starts and stops the services.
You can configure a Sitecore Host application to run as a Windows Service by passing the -s or --service argument to the host application.
Currently this feature is only compatible with Sitecore Host applications that target the full .NET framework. If not, the -s option is not available.
Running the above command from anywhere other than a Windows Service (for example, from the command line) results in the following error message:
Cannot start service from the command line or a debugger. A Windows Service must first be installed (using installutil.exe) and then started with the ServerExplorer, Windows Services Administrative tool or the NET START command.
Install a Sitecore Host application as a Windows Service
Use the following PowerShell command to install a new service:
New-Service -Name "ExampleService" -DisplayName "Example Service" -Description "An Example Service" -StartupType Manual -BinaryPathName "Path-To-App.exe --service"
Start the service
To start the service, use the following Powershell command:
Start-Service -Name "ExampleService"
Stop the service
To stop the service, use the following Powershell command:
Stop-Service -Name "ExampleService"
Uninstall the service
To uninstall the service, use the following Powershell command:
sc.exe Delete "ExampleService"