问题
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