Windows 7 and Vista improve the security of the system. At the same time, you need to explicitly specify "Run as administrator" to give the running software more advanced permissions,
such as access Registry etc. Otherwise, when a program running as a normal identity needs to access higher-level system resources, an exceptionwill be thrown.
How to make the program automatically require "administrator" permissions when it starts, we only need to modify the configuration items in the app.man The app.manifest file does not exist by default. We can automatically add the file through the following operations. (1) Enter the projectProperties page.
(2) Select the "Security" column. (3) Check "Enable ClickOnce Security Settings". Now, the app.manifest file is automatically generated in the Properties directory. Open the file and change the level value of requestedExecutionLevel of the trustInfo/security/requestedPrivileges node torequireAdministrator. . As shown below:
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> </requestedPrivileges>
The above is the detailed content of Analysis of how .NET programs automatically run as administrator. For more information, please follow other related articles on the PHP Chinese website!