Steps:
One: In visual Studio--Solution Explorer--right-click the project name-Properties, find the "security" option
Two: Tick "Enable ClickOnce Security Settings",
Three: At this point, under the project will be more than a "app.manifest" file, select it, and find the code snippet <requestedexecutionlevel level= "AsInvoker" uiaccess= "false"/> Change it to: <requestedexecutionlevel level= "Requireadministrator" uiaccess= "false"/>
Open it:
Modify the section to:
Four: After correcting, do not rush to recompile the build, again open the "Properties--security" interface,
Remove the check in front of "Enable ClickOnce security Settings" before compiling and running. Otherwise, the program will not be able to run error.
Five: Finally, save the changes, recompile the run program.
When the program is opened, user Account Control is prompted for administrator privileges to run, and click Yes to get administrator privileges.
C # Let programs run programs as Administrators