You are viewing our Forum Archives. To view or take place in current topics click here.
Requesting Admin Privileges on App Startup
Posted:

Requesting Admin Privileges on App StartupPosted:

CLK
  • Wise One
Status: Offline
Joined: Jun 12, 201013Year Member
Posts: 531
Reputation Power: 33
Status: Offline
Joined: Jun 12, 201013Year Member
Posts: 531
Reputation Power: 33
As most of you guys probably know, on Windows Vista and Windows 7 if you don't run an application as administrator you can run in to issues with your app crashing or not performing like it should.

This will make your app request admin privileges on startup so that you can avoid those problems, and the user doesn't have to right-click and run as admin.

Ignore that I'm using Party Buffalo as this example, since I already had it open and didn't feel like making a new project.

First, go to Project>Add New Item...

From there, you should be greeted with the window with your options and whatnot. Select "Application Manifest File"

[ Register or Signin to view external links. ]

Once it's been added to the project, right-click it and open.

[ Register or Signin to view external links. ]

The grayed line is what we need to change. Where it says:

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


That needs to be changed to:

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


Next, right-click on the project in the Solution Explorer and choose Properties (or click on the Properties menu at the top and choose YourProjectName Properties...)

In the "Application" tab there should be a "Manifest" combobox right under the Icon one. Click on it, and select the app manifest that we just created (should be named app.manifest by default)

[ Register or Signin to view external links. ]

And there you go! When the app is run on a computer with UAC enabled, it should now come up with the UAC window like this:

[ Register or Signin to view external links. ]
(not my image -- too lazy to enable UAC, restart, etc.)

The following 3 users thanked CLK for this useful post:

Mavhammer (11-05-2011), Fanboy (06-23-2011), FinancialChad (06-21-2011)
#2. Posted:
Sunkist
  • TTG Destroyer
Status: Offline
Joined: Jun 06, 201013Year Member
Posts: 7,311
Reputation Power: 373
Status: Offline
Joined: Jun 06, 201013Year Member
Posts: 7,311
Reputation Power: 373
NERD!

jokes

Thanks man

That Will help my Friend and me
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.