C#.NET: Acquire administrator rights?
Asked Answered
I

2

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

Idolla answered 27/8, 2010 at 11:0 Comment(2)
Does this address your question? * Demand UAC elevation for an application by adding a manifest using mt.exe Here is another one that appears to explain the same thing: * Request UAC Elevation for .NET Application (Managed Code)Ruching
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.Overheat
C
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

Cephalic answered 27/8, 2010 at 11:23 Comment(5)
Link-only answers are poor practice on SETogether
Links are down.Effluence
@Effluence fixedCephalic
@VictorHurdugaci Links are down again.Eduino
Sorry folks, the links are no longer working. My website went through some transformations and those articles are gone now... But you can find them on web archive web.archive.org/web/20160322162954/https://victorhurdugaci.com/…Cephalic
B
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" />
Berkie answered 25/12, 2012 at 21:54 Comment(1)
You can't publish it then.Hyssop

© 2022 - 2024 — McMap. All rights reserved.