简体   繁体   中英

How to run any program with Windows Service as an Administrator privilage

I wrote a code in C# which generates exe and also created a windows service for it.

This windows service simply starts the process of my main program (exe).

When I'm installing the windows service with windows installer which also created by me, everything is ok. My service is installing and it is running my main program. But because it is running it with SYSTEM privileges, my program isn't running as expected.

Is there any way to run it with Administrator privileges?

You can run the service as a specific user by opening up your windows services.

Push the windows key on your keyboard. Then type services.msc and then

Right click on the service you created and click properties.

Go to the "Log On" tab and change from "Local System account" to "This account:"

Then provide credentials for elevated user that has necessary rights.

(Edit) NOTES: when you enter your username and password into that box.. it only validates your username is valid. it does not validate the password is correct. Ensure that your credentials are entered correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM