I am trying to create a service that runs an executable file, .exe
. The problem is that the service is not starting the .exe
, everytime I reboot. It lacks consistency. But when I manually set the startup type to Automatic (Delayed start) it works perfectly. How can I set this startup type to Automatic (Delayed start) via C++?
This is the code I use to start automatically:
How should I change that "Service_auto_start" to Automatic (Delayed start)?
SC_HANDLE schService = CreateService
(
schSCManager, /* SCManager database */
pName, /* Name of service */
pName, /* Service name to display */
SERVICE_ALL_ACCESS, /* Desired access */
SERVICE_WIN32_OWN_PROCESS|
SERVICE_INTERACTIVE_PROCESS , /* Service type */
SERVICE_AUTO_START, /* Start type */
SERVICE_ERROR_NORMAL, /* Error control type */
pPath, /* Service's binary */
NULL, /* No load ordering group */
NULL, /* No tag identifier */
NULL, /* No dependencies */
NULL, /* LocalSystem account */
NULL
);