How do I run my C# service with elevated UAC privileges on Windows 2012r2?

ε祈祈猫儿з 提交于 2019-12-10 17:31:27

问题


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.

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 here to determine if I am running with elevated permissions.

来源:https://stackoverflow.com/questions/30080058/how-do-i-run-my-c-sharp-service-with-elevated-uac-privileges-on-windows-2012r2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!