From e486468edc1cd2facaf6dc392a3a052d35545d73 Mon Sep 17 00:00:00 2001 From: Justin Dearing Date: Tue, 6 Jul 2010 04:42:18 +0800 Subject: [PATCH] Better error message if CreateService() fails. --- util/ntservice.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/util/ntservice.cpp b/util/ntservice.cpp index 85d58eda3e2..e9bc449c409 100644 --- a/util/ntservice.cpp +++ b/util/ntservice.cpp @@ -88,11 +88,12 @@ namespace mongo { SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, commandLineWide.str().c_str(), NULL, NULL, L"\0\0", NULL, NULL ); - if ( schService == NULL ) { - log() << "Error creating service." << endl; - ::CloseServiceHandle( schSCManager ); - return false; - } + if ( schService == NULL ) { + DWORD err = ::GetLastError(); + log() << "Error creating service: " << GetWinErrMsg(err) << endl; + ::CloseServiceHandle( schSCManager ); + return false; + } log() << "Service creation successful." << endl; log() << "Service can be started from the command line via 'net start \"" << toUtf8String(serviceName) << "\"'." << endl;