Running Orthanc in Windows as a service

Hi,
I compiled the orthanc source code as windows binary and it works smootly. However, when I try to run it as a service a got an error 1053.

The command I run:
sc create “OrthancService” binPath= “Path\To\your\Orthanc.exe” DisplayName= “Orthanc Service”

The error I got:
Windows could not start the Orthanc Service on Local Computer.

Error 1503: The service did not respond. to the start or control request in a timely fashion.

Thanks…
Hasan ERKEN

Hi,

Disclaimer: I’m not an expert at all in Windows Services and was not involved in the development of the service.

Note that Orthanc is not a Windows service per se and the OrthancService has an extra executable that is used to launch/stop Orthanc. The full source code of the Orthanc Service is available here: https://bitbucket.org/osimis/orthanc-builder/src/master/WindowsInstaller/Configuration/

Also note that Osimis provides a Windows Installer that takes care of everything, including installing Orthanc as a service: https://www.orthanc-server.com/download-windows.php

HTH,

Alain

Hasan,
The sc create command is not meant to be used with regular executables, but with service executables that must be written in a particular (non-portable) way.

As mentioned by Alain, you either simply use the Orthanc default installer that takes care of this or you can have a look at the Orthanc service wrapper . If you want to do it manually for some reason, I strongly advise against writing your own C++ wrapper and instead use a preexisting service wrapper such as WinSW (https://github.com/winsw/winsw) that is really easy to use.

The following rather old (ableit still perfectly useful) tutorial might help you understand how a service executable works: https://www.codeproject.com/Articles/499465/Simple-Windows-Service-in-Cplusplus