X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=service.cpp;h=09fbe1f0073f1523fcf54523663194c18b838d5c;hb=69df8a039d4a5c6e3e955fe75167bb472292fc1d;hp=57dc7a28f103ff3bc69312b982d53f14c40cd94c;hpb=6a12d5bf24211cfee30c47354b32befc3abae5b8;p=nssm.git diff --git a/service.cpp b/service.cpp index 57dc7a2..09fbe1f 100644 --- a/service.cpp +++ b/service.cpp @@ -80,17 +80,17 @@ void cleanup_nssm_service(nssm_service_t *service) { /* About to install the service */ int pre_install_service(int argc, TCHAR **argv) { + nssm_service_t *service = alloc_nssm_service(); + set_nssm_service_defaults(service); + if (argc) _sntprintf_s(service->name, _countof(service->name), _TRUNCATE, _T("%s"), argv[0]); + /* Show the dialogue box if we didn't give the service name and path */ - if (argc < 2) return nssm_gui(IDD_INSTALL, argv[0]); + if (argc < 2) return nssm_gui(IDD_INSTALL, service); - nssm_service_t *service = alloc_nssm_service(); if (! service) { print_message(stderr, NSSM_EVENT_OUT_OF_MEMORY, _T("service"), _T("pre_install_service()")); return 1; } - - set_nssm_service_defaults(service); - _sntprintf_s(service->name, _countof(service->name), _TRUNCATE, _T("%s"), argv[0]); _sntprintf_s(service->exe, _countof(service->exe), _TRUNCATE, _T("%s"), argv[1]); /* Arguments are optional */ @@ -122,11 +122,13 @@ int pre_install_service(int argc, TCHAR **argv) { /* About to remove the service */ int pre_remove_service(int argc, TCHAR **argv) { + nssm_service_t *service = alloc_nssm_service(); + set_nssm_service_defaults(service); + if (argc) _sntprintf_s(service->name, _countof(service->name), _TRUNCATE, _T("%s"), argv[0]); + /* Show dialogue box if we didn't pass service name and "confirm" */ - if (argc < 2) return nssm_gui(IDD_REMOVE, argv[0]); + if (argc < 2) return nssm_gui(IDD_REMOVE, service); if (str_equiv(argv[1], _T("confirm"))) { - nssm_service_t *service = alloc_nssm_service(); - _sntprintf_s(service->name, _countof(service->name), _TRUNCATE, _T("%s"), argv[0]); int ret = remove_service(service); cleanup_nssm_service(service); return ret;