X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=service.cpp;h=eaeb797a3eb82393d64afdbf2ce3500b4d10ef5e;hb=db1d114d828b28fe91196d0f72e27502a052119b;hp=d7c7e6eaf88a539468ba5a23bf7658f4118125b4;hpb=67795adae06c0f28346818bdd974597cd77a90f1;p=nssm.git diff --git a/service.cpp b/service.cpp index d7c7e6e..eaeb797 100644 --- a/service.cpp +++ b/service.cpp @@ -262,6 +262,7 @@ int get_service_username(const TCHAR *service_name, const QUERY_SERVICE_CONFIG * } int grant_logon_as_service(const TCHAR *username) { + if (! username) return 0; if (str_equiv(username, NSSM_LOCALSYSTEM_ACCOUNT)) return 0; /* Open Policy object. */ @@ -781,9 +782,9 @@ int install_service(nssm_service_t *service) { GetModuleFileName(0, service->image, _countof(service->image)); /* Create the service - settings will be changed in edit_service() */ - service->handle = CreateService(services, service->name, service->name, SC_MANAGER_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, service->image, 0, 0, 0, 0, 0); + service->handle = CreateService(services, service->name, service->name, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, service->image, 0, 0, 0, 0, 0); if (! service->handle) { - print_message(stderr, NSSM_MESSAGE_CREATESERVICE_FAILED); + print_message(stderr, NSSM_MESSAGE_CREATESERVICE_FAILED, error_string(GetLastError())); CloseServiceHandle(services); return 5; }