如何在 Windows 2012r2 上使用提升的 UAC 权限运行我的 C# 服务? [英] How do I run my C# service with elevated UAC privileges on Windows 2012r2?
问题描述
我有一项需要提升管理权限的服务.该服务在 Windows XP 和 Windows 2008r2 上运行良好,但是当我运行检查应用程序是否在 Windows 2012r2 上提升的管理上下文下执行的代码时 - 结果始终为 false.
I have a service which requires elevated administrative permissions. The service runs fine on Windows XP and Windows 2008r2 but when I run the code which checks to see whether the application is executing under an elevated administrative context on Windows 2012r2 - the result is always false.
我已经尝试将 <requestedExecutionLevel level="requireAdministrator" uiAccess="true"/>
添加到应用程序清单中,当我运行与控制台应用程序相同的代码时,这可以正常工作 -但作为一项服务,应用程序只是在没有提升权限的情况下执行 - 无法执行需要管理权限的操作.
I have already tried adding <requestedExecutionLevel level="requireAdministrator" uiAccess="true" />
to the application manifest and this works fine when I run the same code as a console application - but as a service, the application just executes without elevated permissions - failing to perform operations that require the administrative permissions.
此外,我正在使用已接受答案中的代码
Also, I am using the code in the accepted answer
至少需要有 30 个字符才能点击保存按钮.
At least 30 characters need to be present before i can click Save button.
这篇关于如何在 Windows 2012r2 上使用提升的 UAC 权限运行我的 C# 服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!