Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF application manifest file

Tags:

I have a WPF application that I want to make it able to start always as an Adminstrator. I've been reading a lot about it and it seems that I have to create my own manifest file and pass it to the Application properties so that on runtime it starts as an Administrator.

The application itself loads a file and sometimes the file might demand administrator access so it can be modified. That is why I am looking for a way after the Application gets installed to be able to always get started in administrator mode.

like image 893
mathinvalidnik Avatar asked Jul 01 '13 14:07

mathinvalidnik


People also ask

What is an application manifest file?

Every app project must have an AndroidManifest. xml file (with precisely that name) at the root of the project source set. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.

What is manifest file in C#?

The manifest file describes how your application should run. From MSDN: Every assembly, whether static or dynamic, contains a collection of data that describes how the elements in the assembly relate to each other. The assembly manifest contains this assembly metadata.

How do you create a manifest file?

You can tell Visual Studio to generate a manifest file for a particular project in the project's Property Pages dialog. Under Configuration Properties, select Linker > Manifest File > Generate Manifest. By default, the project properties of new projects are set to generate a manifest file.


1 Answers

To add a Manifest, right click on your project file in Solution Explorer:

  1. Select Add

  2. New item

  3. Choose Application Manifest File

The file should be named app.manifest. Don't rename it.


You have to change the <requestedExecutionLevel> element in your Manifest to start always as an Adminstrator:

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

BTW: A good article for this question:
https://docs.microsoft.com/en-us/dotnet/framework/ui-automation/ui-automation-security-overview

like image 69
Smartis Avatar answered Oct 17 '22 03:10

Smartis