Revert ac2480c9: Copy and run client program in ProgramData

Fix: Run as Windows service will fail due to ac2480c9

Improve: Don't check date because trail has been removed
This commit is contained in:
shaun
2025-12-18 11:55:28 +01:00
committed by yuanyuanxiang
parent 602997082e
commit 5ee87d9450
5 changed files with 106 additions and 72 deletions

View File

@@ -344,17 +344,31 @@ BOOL ServiceWrapper_Install(void)
Mprintf("Installing service...\n");
Mprintf("Executable path: %s\n", szPath);
schService = CreateService(
schSCManager,
g_MyService.Name,
g_MyService.Display,
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL,
szPath,
NULL, NULL, NULL, NULL, NULL
);
int retryCount = 5;
for (int i = 0; i < retryCount; i++) {
schService = CreateService(
schSCManager,
g_MyService.Name,
g_MyService.Display,
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL,
szPath,
NULL, NULL, NULL, NULL, NULL
);
if (schService != NULL) {
break; // 成功
}
DWORD err = GetLastError();
if (err == ERROR_SERVICE_MARKED_FOR_DELETE) {
Sleep(2000);
continue;
}
break; // 其他错误,退出
}
if (schService == NULL) {
err = GetLastError();