C # Run the source code with the Administrator permission. C # The software obtains the Administrator permission. c # The software obtains the Administrator permission,

Source: Internet
Author: User

C # Run the source code with the Administrator permission. C # The software obtains the Administrator permission. c # The software obtains the Administrator permission,
C # Run the source code with the Administrator permission. C # The software obtains the Administrator permission. c # The software obtains the Administrator permission.

Release date: Content source:Unknown Click:Times

Windows 7 and vista improve system security. You must specify "Run as administrator" to grant advanced permissions to the running software, such as accessing the registry. Otherwise, an exception is thrown when a program running as a normal user needs to access more advanced system resources.

To enable the program to automatically require the "Administrator" permission during startup, you only need to modify the configuration items in the app. manifest file.

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

(1) Go to the project properties page.

(2) Select "security.

(3) Select "enable ClickOnce Security Settings.

Now, the app. manifest file is automatically generated in the Properties directory. open the file and change the value of requestedExecutionLevel of the trustInfo/security/requestedPrivileges node to requireAdministrator. As follows:

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

If the "ClickOnce does not support request execution level requireAdministrator" error is reported during compilation, remove the xmlns = "urn: schemas-microsoft-com: asm. v3" attribute of requestedPrivileges!

Remember, if you do not need ClickOnce, you can go back to the project properties page and deselect "enable ClickOnce Security Settings.

Next, recompile your program.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.