]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
make service log on as local service builtin account again. There was no issue with...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 21 Aug 2008 12:13:09 +0000 (12:13 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 21 Aug 2008 12:13:09 +0000 (12:13 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10195 e03df62e-2008-0410-955e-edbf42e46eb7

win/win32service.cpp

index 2d9361f22f62628a069ccd7f0e138f9a6ba8979d..0eb9d0c1ac2cef919ea4f5b9a13b4090ac476215 100644 (file)
@@ -14,6 +14,7 @@
 #include <windows.h>\r
 #include <stdlib.h>\r
 #include <string.h>\r
+#include <stdio.h>\r
 \r
 extern int smain(int argc, char** argv);\r
 \r
@@ -176,12 +177,17 @@ void InstallService(void)
 \r
        scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE);\r
        if (!scm)\r
+       {\r
+               printf("Unable to open service control manager: %d\n", GetLastError());\r
                return;\r
+       }\r
 \r
-       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);\r
+       myService = CreateService(scm,"InspIRCd","Inspire IRC Daemon", SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,\r
+               SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, modname, 0, 0, 0, NULL, NULL);\r
 \r
        if (!myService)\r
        {\r
+               printf("Unable to create service: %d\n", GetLastError());\r
                CloseServiceHandle(scm);\r
                return;\r
        }\r
@@ -202,6 +208,7 @@ void InstallService(void)
                        BOOL success = ChangeServiceConf(myService,SERVICE_CONFIG_DESCRIPTION, &svDesc);\r
                        if (!success)\r
                        {\r
+                               printf("Unable to set service description: %d\n", GetLastError());\r
                                CloseServiceHandle(myService);\r
                                CloseServiceHandle(scm);\r
                                return;\r
@@ -210,6 +217,7 @@ void InstallService(void)
                FreeLibrary(advapi32);\r
        }\r
 \r
+       printf("Service installed.\n");\r
        CloseServiceHandle(myService);\r
        CloseServiceHandle(scm);\r
 }\r
@@ -220,22 +228,28 @@ void RemoveService(void)
 \r
        scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE);\r
        if (!scm)\r
+       {\r
+               printf("Unable to open service control manager: %d\n", GetLastError());\r
                return;\r
+       }\r
 \r
        myService = OpenService(scm,"InspIRCd",SERVICE_ALL_ACCESS);\r
        if (!myService)\r
        {\r
+               printf("Unable to open service: %d\n", GetLastError());\r
                CloseServiceHandle(scm);\r
                return;\r
        }\r
 \r
        if (!DeleteService(myService))\r
        {\r
+               printf("Unable to delete service: %d\n", GetLastError());\r
                CloseServiceHandle(myService);\r
                CloseServiceHandle(scm);\r
                return;\r
        }\r
 \r
+       printf("Service removed.\n");\r
        CloseServiceHandle(myService);\r
        CloseServiceHandle(scm);\r
 }\r
@@ -259,7 +273,9 @@ int main(int argc, char** argv)
        }\r
 \r
        /* First, check if the service is installed.\r
-        * if it is not, just call smain().\r
+        * if it is not, or we're starting as non-administrator,\r
+        * just call smain() and start as normal non-service\r
+        * process.\r
         */\r
        SC_HANDLE myService, scm;\r
        scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE);\r