有没有办法以编程方式安装提示权限升级(UAC)的软件?
基本上我要么需要用我的程序单击UAC按钮(我认为这是不可能的),要么以某种方式做到这一点,这样我就不需要单击按钮来安装软件。我还需要在程序安装过程中单击按钮,但我知道该怎么做。我只关心UAC的事情。
Basically I either need to Click the UAC button with my program(which i don't believe is possible) or somehow make it so I don't need to click the button to install the software. I will also need to click buttons during the install with my program but I know how to do that. I am only concerned with the UAC things.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
无论哪种方式,用户都必须单击该按钮才能授予您继续操作的权限。这就是 UAC 的全部意义所在,如果有办法解决它,那它绝对没有任何作用。
您可以提前(在安装开始时)或稍后(在安装过程中第一次实际需要权限时)请求许可,但您必须在其中一次这样做。
标准的操作过程是在您的应用程序中嵌入一个清单,表明您需要管理权限。适用的行如下所示:
或者,您可以选择依赖 UAC 的“安装程序检测” “功能:
在安装过程中单击按钮也不是一个好主意。如果这是您正在编写的安装程序,请在执行安装程序应用程序时指定的一些“静默安装”标志中进行编码。如果您使用的是第三方安装程序,请检查文档;很可能这样的标志已经存在。这些标志的要点是,在设置过程中根本不显示交互式 UI,这意味着没有人需要费心单击任何按钮(这是很难做到正确的)。
One way or the other, the user is going to have to click that button to give you permission to proceed. That's the whole point of UAC, if there were a way to work around it, it would serve absolutely no purpose.
You can either ask for permission sooner (at the beginning of your installation) or later (at the point in the installation when the privileges are first actually required), but you have to do it one of those times.
The standard course of action is to embed a manifest in your application that indicates you require administrative privileges. The applicable line looks like this:
Alternatively, you could choose to rely on UAC's "Installer Detection" functionality:
Clicking buttons during your install isn't a very good idea, either. If this is an installer that you're writing, code in some "silent install" flags that you can specify when executing the installer app. If this is a third-party installer that you're using, check the documentation; chances are such flags already exist. The point of these flags is that interactive UI is not displayed at all during setup, meaning that no one has to bother clicking any buttons (which is very hard to get right).
您可以将程序安装在用户的主目录或任何其他无需管理员权限即可写入的目录中。
如果您正在编写安装程序包装程序,则可以在包装程序上请求 UAC,并且包装程序可以使用管理员权限启动真正的安装程序。大多数安装程序还为无人值守安装提供命令行选项,因此您可能需要检查这些选项,而不是编写按钮单击脚本。
you can install your program in the user's home directory or any other directories which is writable without administrator privilege.
if you're writing an installer wrapper, you can ask for UAC on the wrapper and the wrapper can start the real installer(s) with administrator privilege. Most installers also provides command line options for unattended installations, so you might want to check those instead of scripting button clicks.
您无法单击 UAC 同意对话框上的按钮。
您的其他选择取决于您真正想要实现的目标。因此,请向我们提供有关您的任务的更多详细信息:与单击应用程序中的安装程序按钮相比,可能有更好的设计选择。
为了避免 UAC,您可以安装一个将启动安装的服务。但安装服务时必须征得用户同意。
You can't click button on UAC consent dialog.
Your other options depend on what you really try to achieve. So give us more details on the your task: there could be better design choices than clicking installer buttons from an application.
To avoid UAC, you can install a service which will start the installation. But user has to consent when you install the service.