15

I have a project with a manifest file with the following node:

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

...meaning I want it to only run "as administrator" by default.

from searching around, to make this work I have two options:

  1. "Embed" it.
  2. deploy the manifest file with the exe, and name it YourProject.exe.manifest.

I've tried option 2, and when I run my app it doesn't ask for admin rights?

So, how do I do option 1 in VS2010? I've heard of mt.exe, but this is no good to me as it's done post build. I need the option to part of the solution and the project file itself.

So, how do I make this work? I'll be happy to do 2, but it doesn't seem to work?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
andy
  • 8,775
  • 13
  • 77
  • 122
  • 1
    If you are developing native C++ apps, it's simpler. Just open project properties/Linker/Manifest File,and select a new value for "UAC Execution level". – swigger Apr 16 '13 at 06:05

3 Answers3

22

In Visual Studio 2010 the default setting for a new project is to embed the manifest in the application (option #1). By default though a default manifest is included. What you need to do is add a custom manifest.

  • Right click on the project and select "Add New Item"
  • Select "Application Manifest File"

This will add a file named app.manifest to the project. Open that file and modify the line to be the following

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

This should also work in Visual Studio 2008.

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
8

Under VS2010 it is a little different. Right click the Project and select Properties. Select the "Application" tab and then click "View Windows Settings". This opens the manifest. Then make the changes you need.

2

I just ran into the same problem caused by copying an existing app.manifest into another project (C#).

I fixed it by unloading the project, editing its csproj file and inserting the following section:

<PropertyGroup>
  <ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

This allowed my application to pick up the app.manifest correctly.

Brian THOMAS
  • 482
  • 1
  • 5
  • 19
Jay
  • 9,561
  • 7
  • 51
  • 72