以管理员权限运行服务 [英] Run service with administrator privileges

查看:49
本文介绍了以管理员权限运行服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个作为 Windows 服务运行的应用程序.我真的需要该服务具有管理员权限.我尝试使用 LocalSystem 用户,但它没有足够的权限.这可能吗?我尝试在 app.config 中设置 requireAdministrator.当我这样做时,服务启动然后立即停止.我也尝试过使用其他管理员帐户,但结果相同.

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.

推荐答案

您只需要以管理员用户身份运行它 - 在服务的服务属性中正确设置登录.

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.

这篇关于以管理员权限运行服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆