Run Application in Administrator Mode in VS2010

December 22, 2012 // In: C#

In windows7, Administrator privileges are required to change or access system settings. For the development of such king of applications that need administrator privileges you must apply some settings on your application in the development process.

Applications that are enabled to run as administrator contains  image on its icon.

Run Application In Admin Mode

You can add the function to run application in administrator mode by following simple steps.

Step-1

  • Open your project in Visual Studio 2010
  • Click on Project Menu -> (Your Project) Properties
  • Go to Security Tab
  • Enable ClickOnce Security Setting and Then Disable it again
  • Press CTRL + S to save settings

Step-2

  • In the Solution Explorer Click the arrow at the left of properties folder
  • From the list of files in the properties folder double click on the app.menifest file to open it

Now find

and replace it with

We just change the value of attribute  level from asInvoker to requireAdministrator

Congrats, Your application can run now in administrator mode. You’ll find yellow icon on your application’s exe file’s icon.

Video Tutorial

C# Coding Standards and Best Programming Practice Part-1
Load Data into GridView in ASP.Net