How to start and stop window service without having admin privileges?
My application launch should start my service same way it has to stop once it is closed. I can do this using "Service Controller "
I can install the service with Admin privilege but for starting and stopping the service should not ask admin privileges.
Can anybody tell me how I can achieve this using c#?
I have discovered the way to give a permission to start/stop the service for non admin users. We can provide a group policy for our service so this can be start/stop without administrator privilege. I found two approach to achieve this task.
Approach 1 :
This approach works perfectly fine, I have created two non admin user account in one virtual machine and set the permission from admin account, I could able to start and stop the service from both non admin user accounts. However this approach was not a complete solution for the problem, It involves lot of manual steps. So I start looking automate this process. Result of that I found the approach 2
Approach 2 : Grant the permission using “Subinacl.exe”, SubInACL is a command-line tool that enables administrators to obtain security information about files, registry keys, and services, and transfer this information from user to user, from local or global group to group, and from domain to domain.
I followed the same example of create two non admin user account and execute command SUBINACL /SERVICE \DomainName\MyService /GRANT=DomainName\USERS=TOP so this will grant the user to start/stop the service.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With