From c1a2a8abca5430a41d145de5c7a7521fe3f3fae5 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 21 Aug 2008 12:13:09 +0000 Subject: make service log on as local service builtin account again. There was no issue with privileges except the fact i was using encryption on my files. doh. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10195 e03df62e-2008-0410-955e-edbf42e46eb7 --- win/win32service.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'win') diff --git a/win/win32service.cpp b/win/win32service.cpp index 2d9361f22..0eb9d0c1a 100644 --- a/win/win32service.cpp +++ b/win/win32service.cpp @@ -14,6 +14,7 @@ #include #include #include +#include extern int smain(int argc, char** argv); @@ -176,12 +177,17 @@ void InstallService(void) scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE); if (!scm) + { + printf("Unable to open service control manager: %d\n", GetLastError()); return; + } - myService = CreateService(scm,"InspIRCd","Inspire IRC Daemon", SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, modname, 0, 0, 0, 0, 0); + myService = CreateService(scm,"InspIRCd","Inspire IRC Daemon", SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, + SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, modname, 0, 0, 0, NULL, NULL); if (!myService) { + printf("Unable to create service: %d\n", GetLastError()); CloseServiceHandle(scm); return; } @@ -202,6 +208,7 @@ void InstallService(void) BOOL success = ChangeServiceConf(myService,SERVICE_CONFIG_DESCRIPTION, &svDesc); if (!success) { + printf("Unable to set service description: %d\n", GetLastError()); CloseServiceHandle(myService); CloseServiceHandle(scm); return; @@ -210,6 +217,7 @@ void InstallService(void) FreeLibrary(advapi32); } + printf("Service installed.\n"); CloseServiceHandle(myService); CloseServiceHandle(scm); } @@ -220,22 +228,28 @@ void RemoveService(void) scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE); if (!scm) + { + printf("Unable to open service control manager: %d\n", GetLastError()); return; + } myService = OpenService(scm,"InspIRCd",SERVICE_ALL_ACCESS); if (!myService) { + printf("Unable to open service: %d\n", GetLastError()); CloseServiceHandle(scm); return; } if (!DeleteService(myService)) { + printf("Unable to delete service: %d\n", GetLastError()); CloseServiceHandle(myService); CloseServiceHandle(scm); return; } + printf("Service removed.\n"); CloseServiceHandle(myService); CloseServiceHandle(scm); } @@ -259,7 +273,9 @@ int main(int argc, char** argv) } /* First, check if the service is installed. - * if it is not, just call smain(). + * if it is not, or we're starting as non-administrator, + * just call smain() and start as normal non-service + * process. */ SC_HANDLE myService, scm; scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE); -- cgit v1.2.3