Home > Backend Development > C#.Net Tutorial > Analysis of how .NET programs automatically run as administrator

Analysis of how .NET programs automatically run as administrator

黄舟
Release: 2017-03-15 10:23:06
Original
1962 people have browsed it

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 exception

will 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

ifest file.

The app.manifest file does not exist by default. We can automatically add the file through the following operations.

(1) Enter the project

Properties 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 to

requireAdministrator. . As shown below:

      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">         
      <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />      
      </requestedPrivileges>
Copy after login


Remember, if you do not need ClickOnce, you can go back to the project properties page and change "Enable ClickOnce Security Settings" is unchecked.​

Next, recompile your program and it will be OK.

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template