0

I have a Windows service(C#) which will be kicked off by an app(.exe). Since we need Admin privileges to start/Stop/Query status of the service. we are running this app in Admin mode.

But, we want to make it to run in 'asInvoker' mode. thus made me think of possibility of start/stop or query status of the Windows Service from an app(.exe) running in asInvoker(Basically non-Admin) Mode. Is it possible to tweak the windows service that way?

Any other constructive solutions are most welcome.

Programmerzzz
  • 1,237
  • 21
  • 48
  • A service runs as whatever user account it is configured to run as when it is installed, not the user account that is asking the SCM to start the service. `asInvoker` does not really apply in this case. – Remy Lebeau Jul 28 '15 at 23:24
  • So, you saying that we need to install/Code the Service to tell it that it can be invoked by non-Admin users? Isn't that if its a Windows Service, user have to have Admin rights to start/Stop or Query its status? meaning..Can we have Windows Services, which can be started/Stopped by non admins ? – Programmerzzz Jul 28 '15 at 23:27
  • My C# service wasn't given any Account as such to run under. Therefore I guess its using local user account. But when ever the other exe which is triggering this service starts, UAC is being displayed. Basically we just wanna get rid of that UAC and make the app start directly which triggers windows service. we don't wanna edit any Registry or control panel values to disable UAC etc.. as they are vulnerable.we just want to make our App not to display the UAC and our service to run. – Programmerzzz Jul 28 '15 at 23:52
  • Yes, you can make a service that can be started by non-admins, as shown in the question linked to above. (I've just added information about granting stop service permission as well.) – Harry Johnston Jul 29 '15 at 04:03
  • @HarryJohnston A couple of outage questions, 1. Firstly, my service is a C# service and do you have a source to kick start a Windows Service by a non Admin in C#? Secondly, My windows Service does many tasks that need Admin pesmissions like writing to Application Log, HKEY\Machine registry etc.. will they still function without throwing an exception after we start the service by a Non Admin Application? – Programmerzzz Jul 29 '15 at 16:33
  • (1) No, I don't have C# code to change the service permissions. Not quite a duplicate, then; I've retracted the close vote. It should be reasonably straightforward to port [the code in my previous answer](http://stackoverflow.com/questions/8379697/start-windows-service-from-application-without-admin-rightc) via P/Invoke, or there may be a .NET API that will do it more easily, but I'll leave that for a C# programmer to attempt. (2) Yes, services run in the same security context (determined by their configuration) regardless of who starts them. – Harry Johnston Jul 29 '15 at 21:36

0 Answers0