Set administrative privileges in C#

十年热恋 提交于 2020-01-17 01:44:10

问题


I have been writing many scripts using WMI and a lot of them only work if I start visual studio with "Run as Administrator".

Is there a way to set that programmatically with .Net or other means?

Eventually, these scripts will be run as .exes from Unity3D so I need to automate setting these rights before running them. Ideally I'm hoping this can all be done in C#.


回答1:


This question was answered in the comments. The only way is to add a manifest file to your project that sets the required priviledges of your app to be administrative. Big thanks to Peter Ritchie and DJ KRAZE!



来源:https://stackoverflow.com/questions/11785413/set-administrative-privileges-in-c-sharp

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