else if (1 == argc){if (0 == isAdmin()){printf("Start Service - Must be run as an administrator to use this operation\n");ReportError(TRUE, "Start Service - Must be run as an administrator to use this operation\n");return -1;}printf("%s: StartServiceCtrlDispatcher to run.\n", __FUNCTION__);ReportError(FALSE, "%s: StartServiceCtrlDispatcher to run.\n", __FUNCTION__);StartServiceCtrlDispatcher(ServiceTable);return 0;}其中,isAdmin和ReportError是我寫的函數,isAdmin()判斷是否具有Administrator權限,ReportError()將后邊的內容寫入到system event log中.我在Service Management中手動啟動這個服務,可以看到event log中有成功字樣,而且service也處于了Started狀態.但是,如果我在具有admin權限的cmd中執行這個service .exe,雖然在console和event log都有成功的字樣,但是在Service Management中該service并未啟動(已按F5刷新了),而且Task Manager里也沒有service .exe的進程.
添加回答
舉報
0/150
提交
取消