Read-write error due to UAC under [C #] Resolver vista/win7

Source: Internet
Author: User

In Microsoft's operating system, Vista and Win7 have added UAC functionality, and UAC (user Account Control, username controls) is a new technology that Microsoft introduced in Windows Vista to improve system security. It requires users to provide permissions or administrator passwords before performing actions that might affect the operation of the computer or make changes that affect other users ' settings. By validating these operations before they are started, UAC can help prevent malware and spyware from installing on the computer or making changes to the computer without permission.

As shown in, programs that are not part of Windows require your permission to start. It has a valid digital signature that indicates its name and publisher, and the digital signature helps ensure that the program is the program it claims to be. Make sure the program is the program you want to run.

But this for us, there will be a situation, we develop the program by default does not give IT administrator permissions, if we put the program installed into the system disk, then some read-write program directory under the operation of the configuration file will not be executed correctly, because the UAC block, But the program can't tell us when to block, because we can't get the blocking information to UAC.

Unfortunately, we recently developed the process of this problem, testing a lot of times, a customer with Win7 system to give us back the problem, I think and search MSDN, I thought about it, there are about 3 ways to solve, to share with you:

1: turn off the user's UAC feature (obviously this method for the customer is a bit unreliable, but here I also mention, because I am particularly annoying UAC reminder, so to shut down, the program has been no error).

Close method "Control Panel-user account and Family Safety-user account-user Account Control Settings", set to "Never Notify", save, restart is OK.

2: This method is very simple, that is, when running the right button "Run as Administrator." It is also possible to resolve this issue, but it is also difficult to accept for those users who want to run directly on a direct click.

3: This method is more long, the solution is also from our own procedures to solve. Let me write the steps:

<1>. In the project, "New Item", select "Application Manifest" and name the file itself as shown in:

<2>. Open the created manifest file with a. manifest extension to view the code, such as:

We can see that there is a comment stating the UAC option, and we need to change the content of this node:

<requestedexecutionlevel level= "asInvoker" uiaccess= "false"/> will AsInvoker, change to Requireadministrator, literally, we can all see that this is the request to run with administrator privileges. Of course there is an option, highestavailable, there is no direct translation on the Internet, but from the literal understanding, is to get the highest execution permissions, this can be set according to their actual situation.

<3>. Open the project properties and select the list item in application-resources as the manifest file that you created.

And then generate the app to do it.

The article to this basic end, here is simply to solve the problem of their own, the online query, a lot of English is introduced, helpless brother E is not too good, reluctantly read some, practice a bit, solve the problem in hand, hoping to help meet the same problems of friends. Note: VS2008 and VS2010 to add the list, as in this article, VS2005 will be more troublesome, I only installed on the machine 08 and 10, no attempt to use 05 solution, please install 05 of the brothers try to solve their own, or upgrade to 08 or 10.

Reference documents:

1:using manifests to Elevate a application in Vista

2:create and Embed an application Manifest (UAC)

Read-write error due to UAC under [C #] Resolver vista/win7

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.