VB - Run application as administrator automatically

In this tutorial you will learn how you can make your application launch in administrator mode automatically.

You will need:

*Your application
*Visual Studio (or visual basic 2010).

Start by opening your solution file.

Double click the My project item in the solution explorer (at the right of visual basic/studio):

A new tab should open up:

Click the View Windows Settings button in order to change the application manifest file.

A new tab should open up with a bunch of codes in it.
Most of the code in it is irrelevant to this tutorial. There is only one line that we need (marked in blue):

To make our application run as administrator, there is only one word that we need to change, and that is the level of requestedExecutionLevel.

Change asInvoker to requireAdministrator:

Save your project, and rebuild your solution.

When you take a look at the icon of your executable you will notice a huge difference:




You will now only be able to open your executable if you run it in administrator mode. This opens up a window of new possibilities that you can do, now that your application has administrator rights.

If you have any more questions, please ask them in the comment section below !

Topic: VB - Run application as administrator automatically

Date: 12/11/2013

By: Denis

Subject: manifest

Hi, I tried this approach but it doesn´t work. The App.manifest file keeps the changes but the program is not executed as administrator.
I use Windows 7 64 Sp1 and VB 2010 Sp1.
Thanks in advance.