Feature request: run as windows service #527

Open
opened 2025-11-20 04:24:44 -05:00 by saavagebueno · 1 comment
Owner

Originally created by @shikulja on GitHub (May 19, 2025).

When the application is installed and run as a Windows service without using nssm, it often hangs in the "Starting" state and never fully transitions to "Running." This happens because the application is not designed to properly interact with the Windows Service Control Manager (SCM) interface.

Specifically:

Windows services must respond to SCM control requests (like Start, Stop, Pause) and report their status changes promptly.
A service application needs to call StartServiceCtrlDispatcher and implement a service main function that communicates with the SCM.
If the application is a regular console or GUI program that does not implement the Windows service protocol, SCM will wait indefinitely for a successful start notification.
Without this handshake, SCM assumes the service is stuck, leaving it in the "Starting" state.
nssm works around this by acting as a service wrapper: it runs the console application as a child process and handles SCM communication itself, preventing the service from hanging.

Originally created by @shikulja on GitHub (May 19, 2025). When the application is installed and run as a Windows service without using nssm, it often hangs in the "Starting" state and never fully transitions to "Running." This happens because the application is not designed to properly interact with the Windows Service Control Manager (SCM) interface. Specifically: Windows services must respond to SCM control requests (like Start, Stop, Pause) and report their status changes promptly. A service application needs to call StartServiceCtrlDispatcher and implement a service main function that communicates with the SCM. If the application is a regular console or GUI program that does not implement the Windows service protocol, SCM will wait indefinitely for a successful start notification. Without this handshake, SCM assumes the service is stuck, leaving it in the "Starting" state. nssm works around this by acting as a service wrapper: it runs the console application as a child process and handles SCM communication itself, preventing the service from hanging.
Author
Owner

@shikulja commented on GitHub (Jun 8, 2025):

It is possible to do this using third-party programs. But I found it non-trivial for such a simple task.

nssm+powershell
ddns-updater.zip

@shikulja commented on GitHub (Jun 8, 2025): It is possible to do this using third-party programs. But I found it non-trivial for such a simple task. nssm+powershell [ddns-updater.zip](https://github.com/user-attachments/files/20644717/ddns-updater.zip)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ddns-updater#527