我可以阻止可执行文件请求 UAC 提升吗? [英] Can I stop an executable from requesting UAC elevation?

查看:36
本文介绍了我可以阻止可执行文件请求 UAC 提升吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装程序,我想从脚本运行.安装程序请求 UAC 提升,但它不需要提升,因为我正在安装到用户目录.有什么方法可以运行安装程序,使其不请求 UAC 提升?

I have an installer I'd like to run from a script. The installer requests UAC elevation but it doesn't need elevation because I'm installing to a user directory. Is there some way to run the installer so that it doesn't request UAC elevation?

脚本是用 Python 编写的,所以我可以通过 ctypes 访问 Windows API.

The script is written in Python so I can access the Windows API through ctypes.

更改安装程序不是一种选择.

Changing the installer is not an option.

推荐答案

您必须将您的流程的环境变量 __compat_layer 设置为 RunAsInvoker.然后您可以在没有任何 UAC 提示的情况下运行可执行文件.

You have to set the enviromnet variable __compat_layer for your process to RunAsInvoker. Then you can run the executable without any UAC prompt.

您可以使用 Windows API 函数 SetEnvironmentVariable 用于此目的.

You can use the Windows API function SetEnvironmentVariable for this purpose.

这篇关于我可以阻止可执行文件请求 UAC 提升吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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