From bee23f2578108077f3cd3e192a68b05cb35b799e Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 20 Jun 2024 15:40:56 +0200 Subject: [PATCH] Let Windows service start automatically, but delayed so the network has enough time to get up. --- icinga-app/icinga.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 1811c8e0740..0a6afe49436 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -773,6 +773,14 @@ static int SetupService(bool install, int argc, char **argv) return 1; } + SERVICE_DELAYED_AUTO_START_INFO sdDASI = { TRUE }; + if (!ChangeServiceConfig2(schService, SERVICE_CONFIG_DELAYED_AUTO_START_INFO, &sdDASI)) { + printf("ChangeServiceConfig2 failed (%d)\n", GetLastError()); + CloseServiceHandle(schService); + CloseServiceHandle(schSCManager); + return 1; + } + if (!StartService(schService, 0, nullptr)) { printf("StartService failed (%d)\n", GetLastError()); CloseServiceHandle(schService);