如何设置“以管理员身份运行"MSI 安装程序创建的快捷方式上的标志 [英] How to set "Run as administrator" flag on shortcut created by MSI installer

查看:81
本文介绍了如何设置“以管理员身份运行"MSI 安装程序创建的快捷方式上的标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual Studio 2010 中有一个安装和部署项目.

I have a Setup and Deployment project in Visual Studio 2010.

我希望安装程序在我的解决方案中为另一个项目的可执行文件创建两个快捷方式.一个普通快捷方式仅使用当前凭据运行应用程序,另一个设置了以管理员身份运行标志,从而确保在单击快捷方式时要求用户提供具有管理权限的凭据.

I would like the installer to create two shortcuts to the executable of another project in my solution. One normal shortcut that simply runs the application using current credentials and another which has the Run as administrator flag set, thereby ensuring that the user is asked for credentials with administrative rights when clicking the shortcut.

以管理权限运行应用程序会启用某些原本不可用的功能.

Running the application with administrative rights enables certain features that are otherwise not available.

乍一看似乎不可能设置此标志.这可以直接在 Visual Studio 中完成吗?如果没有,还有其他选择吗?

Setting this flag doesn't seem to be possible at first glance. Can this be done directly in Visual Studio? If not, are there any other options?

如果没有,是否可以使用自定义安装程序类以编程方式修改快捷方式?

If not, is it possible to modify the shortcut programmatically using a custom installer class?

推荐答案

Windows Installer 不支持此设置.海拔通常由应用程序通过其清单处理.

This is not supported by Windows Installer. Elevation is usually handled by the application through its manifest.

一个解决方案是创建一个使用 ShellExecuterunas 动词以管理员身份启动您的应用程序.然后,您的快捷方式可以指向这个包装器,而不是实际的应用程序.

A solution is to create a wrapper (VBScript or EXE) which uses ShellExecute with runas verb to launch your application as an Administrator. Your shortcut can then point to this wrapper instead of the actual application.

这篇关于如何设置“以管理员身份运行"MSI 安装程序创建的快捷方式上的标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆