c # .exe run as administrator

 
Join MANIFEST resource file in the program
First, open the Vs project, to see whether there is app.manifest Properties in this document;

 

If not, right-click the project choose "Properties" from the menu,

 

 
When you select "Security", check the "Enable ClickOnce Security Settings" in the interface, it is automatically generated app.manifest file under Properties.
Open app.manifest file, locate the following code:
<requestedExecutionLevel level="asInvoker" uiAccess="false" />  
Be amended to:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
 
Then in the "Security" in the hook again go after the "Enable ClickOnce Security Settings", recompile it.

Guess you like

Origin www.cnblogs.com/MrLiang8080/p/11404801.html