Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

c# - 如何强制.NET应用程序以管理员身份运行?(How do I force my .NET application to run as administrator?)

将程序安装在客户端计算机上后,如何强制程序在Windows 7上以管理员身份运行?

  ask by Gold translate from so

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

1 Answer

0 votes
by (71.8m points)

You'll want to modify the manifest that gets embedded in the program.

(您将需要修改嵌入到程序中的清单。)

This works on Visual Studio 2008 and higher: Project + Add New Item, select "Application Manifest File".

(这适用于Visual Studio 2008和更高版本:Project + Add New Item,选择“ Application Manifest File”。)

Change the <requestedExecutionLevel> element to:

(将<requestedExecutionLevel>元素更改为:)

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

The user gets the UAC prompt when they start the program.

(用户在启动程序时收到UAC提示。)

Use wisely;

(明智地使用;)

their patience can wear out quickly.

(他们的耐心会很快耗尽。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...