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. |