19

Is it possible in a C#.NET application to request administrative rights on a Windows 7 PC?

I want to be able to deploy the application via Click Once and have users use it to perform administrative tasks (in this case it is writing registry entries for the main application).

Turing Complete
  • 929
  • 2
  • 12
  • 19
  • Does this address your question? * [Demand UAC elevation for an application by adding a manifest using mt.exe](http://community.bartdesmet.net/blogs/bart/archive/2006/10/28/Windows-Vista-_2D00_-Demand-UAC-elevation-for-an-application-by-adding-a-manifest-using-mt.exe.aspx) Here is another one that appears to explain the same thing: * [Request UAC Elevation for .NET Application (Managed Code)](http://www.aneef.net/2009/06/29/request-uac-elevation-for-net-application-managed-code/) – Timwi Aug 27 '10 at 11:11
  • 1
    I suppose this was required for VS2005, but with VS2008 (and above, I guess), simply add a new item to your project, select **Application Manifest File** as template. Then edit this file and set `level="requireAdministrator"` as explained in the xml comments. – Benlitz May 06 '12 at 23:48

2 Answers2

15

http://victorhurdugaci.com/using-uac-with-c-part-1

http://victorhurdugaci.com/using-uac-with-c-part-2

http://victorhurdugaci.com/using-uac-with-c-part-3

*self promotion

Extra characters because it must be 30

Victor Hurdugaci
  • 28,177
  • 5
  • 87
  • 103
7

simply all what you need to do is to add manifest application file to your project

simple : right click on the project , add , new item , manifest file


and Change the

 <requestedExecutionLevel  level="asInvoker" uiAccess="false" />

to

 <requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Bilal
  • 91
  • 1
  • 1