X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=nssm.cpp;h=6456c9735c4066a8f7fed4222def6077714a8b36;hb=b0a6672810ee06052dc3dcf268274d06f0e82a50;hp=37f3aea34e9f608c794a5215285873e422326e5d;hpb=f1d6394333ce0f90c423d74a9860620942f2bb6f;p=nssm.git diff --git a/nssm.cpp b/nssm.cpp index 37f3aea..6456c97 100644 --- a/nssm.cpp +++ b/nssm.cpp @@ -55,26 +55,6 @@ void check_admin() { FreeSid(AdministratorsGroup); } -/* See if we were launched from a console window. */ -static void check_console() { - /* If we're running in a service context there will be no console window. */ - HWND console = GetConsoleWindow(); - if (! console) return; - - unsigned long pid; - if (! GetWindowThreadProcessId(console, &pid)) return; - - /* - If the process associated with the console window handle is the same as - this process, we were not launched from an existing console. The user - probably double-clicked our executable. - */ - if (GetCurrentProcessId() != pid) return; - - /* We close our new console so that subsequent messages appear in a popup. */ - FreeConsole(); -} - int num_cpus() { DWORD_PTR i, affinity, system_affinity; if (! GetProcessAffinityMask(GetCurrentProcess(), &affinity, &system_affinity)) return 64; @@ -105,6 +85,11 @@ int _tmain(int argc, TCHAR **argv) { */ if (str_equiv(argv[1], _T("start"))) exit(control_service(NSSM_SERVICE_CONTROL_START, argc - 2, argv + 2)); if (str_equiv(argv[1], _T("stop"))) exit(control_service(SERVICE_CONTROL_STOP, argc - 2, argv + 2)); + if (str_equiv(argv[1], _T("restart"))) { + int ret = control_service(SERVICE_CONTROL_STOP, argc - 2, argv + 2); + if (ret) exit(ret); + exit(control_service(NSSM_SERVICE_CONTROL_START, argc - 2, argv + 2)); + } if (str_equiv(argv[1], _T("pause"))) exit(control_service(SERVICE_CONTROL_PAUSE, argc - 2, argv + 2)); if (str_equiv(argv[1], _T("continue"))) exit(control_service(SERVICE_CONTROL_CONTINUE, argc - 2, argv + 2)); if (str_equiv(argv[1], _T("status"))) exit(control_service(SERVICE_CONTROL_INTERROGATE, argc - 2, argv + 2));