views:

67

answers:

2

How to set execution level for .Net application to run with administrator privileges when it is run in normal User account on Win XP ?

+2  A: 

You'll need to create an application manifest with a level-requirement such at this:

<requestedExecutionLevel level="requireAdministrator" uiAccess="true|false"/>

Source: http://msdn.microsoft.com/en-us/library/bb756929.aspx Full example: http://www.enusbaum.com/blog/2007/08/26/how-to-run-your-c-application-as-administrator-in-windows-vista/

Martin Eve
A: 

the code requires an elevated privilege to access registry. However there is just a fragment of code that requires these extra permission. To handle such scenarios impersonation is used i.e. you will execute this application as normal user only but that particular piece of code will be executed as if you were an Administrator.

http://msdn.microsoft.com/en-us/library/system.security.principal.windowsimpersonationcontext.aspx

Anuya