Reputation:
I created a Windows service for my application using a batch file containing the instruction:
sc create <name> binPath= "C:\my\path\" DisplayName= "MyName"
The service is created successfully and the application runs without issues. The Windows Service Manager shows the service in the list, however it does not have the "started" status, even though it is running. Clicking on "start service" fails with "Error 1053: The service did not respond to the start or control request in a timely fashion".
When attempting to control the service using the net
command, such as
net stop <name>
or
net start <name>
these commands fail with similar error messages.
This happens consistently on all Windows I tested on (up to Windows 7). Restarting the machine does not change anything.
Any reason why a successfully created and running service cannot be started or stopped (or even have its status recognized)?
Upvotes: 0
Views: 880
Reputation: 109005
(Including information from comments to the question.)
Linux daemon processes are controlled through signals.
Windows Services have a completely model. The process needs to connect to the Service Control Manager (SCM: the services.exe
process) on start up to provide a callback. This callback is the main entry to the service, and also how the SCM signals important events (eg. that the service should stop).
This is covered on MSDN, and .NET has specific support (by subclassing ServiceBase
.)
It maybe possible to find a helper program that provides the SCM integration and launches you program, but likely it will just terminate your processes (*nix style signals do not exist on Windows) on the SCM sending a stop.
Upvotes: 2