How to Programmatically select the Run this program as an Administrator Checkbox option for C# Application exe in Windows 10?

huangapple go评论70阅读模式
英文:

How to Programmatically select the Run this program as an Administrator Checkbox option for C# Application exe in Windows 10?

问题

我想要默认启用“以管理员身份运行此程序”复选框选项,以便不需要用户每次右键单击exe并选择“以管理员身份运行”。1)在构建.NET应用程序时,是否有办法以编程方式启用此选项?2)在创建MSI安装程序时,是否可能设置此复选框启用?

手动启用选项的步骤

  1. 右键单击C# EXE
  2. 选择属性
  3. 转到兼容性选项卡
  4. 选择“以管理员身份运行此程序”复选框

请参考附图:

查看C# Exe属性的图像

英文:

I would like to set the "Run this program as an Administrator" Checkbox option enabled by default. So that it does not require user to Right click on exe and select Run As administrator every time.

  1. While building the exe in .Net Application, is there any way to enable this option programmatically?
  2. While Creating MSI installer, is it possible to set this checkbox enable?

Steps to Manually Enable Option

  1. Right click on C# EXE
  2. Select Properties
  3. Go to compatibility tab
  4. Choose Run this program as an Administrator Checkbox

Refer the attached Image

Image of C# Exe Properties

答案1

得分: 2

你可以使用选项"requestedExecutionLevel"和值"requireAdministrator"来编写或生成应用程序清单文件。

更多详情请参考:https://learn.microsoft.com/en-us/previous-versions/bb756929(v=msdn.10)?redirectedfrom=MSDN。

英文:

I suppose you can write or generate Application Manifest file with option "requestedExecutionLevel" and value "requireAdministrator".

See https://learn.microsoft.com/en-us/previous-versions/bb756929(v=msdn.10)?redirectedfrom=MSDN for more details.

huangapple
  • 本文由 发表于 2023年4月10日 20:21:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75977080.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定