Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

c# - WPF application manifest file

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...