startService from non-admin account
-
Hi! I have an application that starts a service application when it starts. This works when I start the application in an admin account, but if I run the program in a non-admin account I'am not able to start the service with the method StartService(). Here is my code: void startmyService() { SC_HANDLE myManager; SC_HANDLE myService; myManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); myService = OpenService(myManager, "myService app", SERVICE_ALL_ACCESS); if (myService == NULL) { return false; } if (!StartService(myService,0,NULL)) { return false; } CloseServiceHandle(myService); return true; }
-
Hi! I have an application that starts a service application when it starts. This works when I start the application in an admin account, but if I run the program in a non-admin account I'am not able to start the service with the method StartService(). Here is my code: void startmyService() { SC_HANDLE myManager; SC_HANDLE myService; myManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); myService = OpenService(myManager, "myService app", SERVICE_ALL_ACCESS); if (myService == NULL) { return false; } if (!StartService(myService,0,NULL)) { return false; } CloseServiceHandle(myService); return true; }
Your account does not have the privilege to start a service. Impersonate an account that has the privilege and then RevertToSelf when done.