The registry access fails because you need to set the boot entry without administrator rights
C # Run as Administrator WinForm program reprint https://www.bbsmax.com/A/obzbkKrQJE/The original 2016-07-29 of the fish Luo
Recently helped customers develop the WinForm client, part of the process of use, there will be "system files not found" error message.
After debugging, it is OK to run the direct administrator right when the program is working on the configuration file and the system permissions are causing the error.
Consider the convenience of user actions, set to get system administrator permissions by default for each run, following the setup steps.
1. In visual Studio--Solution Explorer--right-click the project name-Properties, find the "security" option, tick "Enable ClickOnce Security Settings":
2, at this time, under the project will be more than a "app.manifest" of the file,
Select it and locate the code snippet <requestedexecutionlevel level= "AsInvoker" uiaccess= "false"/>
Change it to: <requestedexecutionlevel level= "Requireadministrator" uiaccess= "false"/>
3, 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.
4. Finally, save the changes and recompile the build program.
When the program is opened again, "User Account Control" will be prompted for administrator privileges to run, click "Yes" to get administrator rights.
VS Development WinForm Settings WinForm get admin rights start