Run service with administrator privileges
Asked Answered
M

1

6

I am developing an application that runs as a windows service. I really need the service to have administrator privileges. I tried with the LocalSystem user, and it does not have enough rights. Is this possible? I tried setting requireAdministrator in the app.config. When I do this, the service starts and then immediately stops. I have tried with other administrator accounts as well, but I get the same results.

Millsaps answered 6/4, 2014 at 0:49 Comment(1)
The problem was that I was adding the requireAdministrator in the app.config not the app.manifest. Once I got it in the right place, everything worked like it was supposed to.Millsaps
S
3

You just need to run it as an admin user - set the login correctly in the services properties for the service.

Usually though it's best to run as an ordinary user and give it explicit permissions to the resources it needs access to.

Southland answered 6/4, 2014 at 0:52 Comment(2)
Thank you. I figured out what I was doing wrong, see my comment above. How would I go about giving explicit permissions? This is the first time I have really needed to change the permissions in the manifest. I can do some research, just figured helpful tips on where to get started are always nice. The reason I need admin privileges is that I require direct drive access to some drives.Millsaps
It depends what you're trying to access - LocalSystem is an administrator service account anyway, so it should already have permissions to local drives.Southland

© 2022 - 2024 — McMap. All rights reserved.