在 Windows 7 中自动执行 UAC 提示
遵循此链接,我一直在尝试找到处理 UAC
提示的解决方案。
我需要测试一个使用 UAC 提示的应用程序。这是必须的,我需要检查它是否弹出并进一步继续。我想自动化这件事,但我还没有找到解决方案。
Following up this link, I have been trying to find a solution to handle the UAC
prompt.
I need to test an application which prompts with UAC. It is a must and i need to check if it popped out and proceed further. I want to automate this thing but i found no solution yet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这在技术上是可行的。您需要编写一个作为 LocalSystem 运行的服务。从那里您可以在安全的 Winlogon 桌面中启动帮助程序进程。从那里您可以安装一个挂钩并检查 UAC 提示,然后以编程方式单击相应的按钮。这是一项繁重的工作,而且相当痛苦。 这是不久前的一个答案,我在其中更详细地讨论了它。我可能还把代码放在某个地方。
更新:哈哈。刚刚注意到我回答了您链接到的问题。我猜你正在尝试在 vbscript 或 vb.net 而不是 C++ 中执行此操作;那是行不通的。
This is technically possible. You need to write a service that runs as LocalSystem. From there you launch a helper process in the secure Winlogon desktop. From there you can install a hook and check for the UAC prompt and programmatically click the appropriate button. It is a lot of work and quite a pain. Here's an answer from a while ago where I discuss it in a little more detail. I probably still have the code lying around somewhere.
Update: LOL. Just noticed that I answered the question you linked to. I guess you are trying to do this in vbscript or vb.net instead of C++; that's just not going to work.
我用 VBScript 和 C#/VB.Net 编写了一个应用程序来自动化 UAC(包括在安全桌面上)。它只能在测试环境中用于测试自动化(鉴于 UAC 无处不在,没有它进行测试似乎很愚蠢!)
您可以在这里下载它(免费):
http://www.brekit.com/
那里还有一个链接,介绍如何通过使用清单并修改 UAC 设置来“以 Microsoft 方式”自动化 UAC,以便它不会出现在您的安全桌面上。
I wrote an application to automate UAC (including on the Secure Desktop) in VBScript and C#/VB.Net. It is only to be used in test environments for test automation (given that UAC is everywhere, it seems daft to test without it!)
You can download it (for free) here:
http://www.brekit.com/
There is also a link there on how to automate UAC "the Microsoft way" by using a Manifest and modifying your UAC Settings so that it does not appear on your Secure Desktop.
你不能那样做。
UAC 用于确保管理操作需要用户提示。
UAC 在激活时会禁用您的 vbscript 和 vb.net。如果您找到解决方法,那么它是一个漏洞/错误,当微软发现它时,很可能会修复它。
You cannot do that.
UAC is for making sure that administrative actions require a user prompt.
UAC disables your vbscript and vb.net when its active. If you find a way around it its an exploit/bug thats likely to be fixed when its discovered by microsoft.
上面给出了简短的回答:不,你不能。
如果您有兴趣了解原因,请阅读以下内容:
没有办法“自动化”UAC。用户帐户控制的开发是为了避免恶意软件(病毒、间谍软件、广告软件等)在目标计算机上运行。
它类似于基于 *nix 的系统(Mac OS X 和许多 Linux 发行版)上的权限对话框,每当需要执行某些需要提升权限的代码(例如,安装应用)。
Windows 的问题在于,在以前的版本 (Windows XP) 中,不需要的软件非常容易在目标计算机上执行代码并危害整个系统。这样做是为了让用户知道什么时候某人/某事想要访问比默认情况下通常可以访问的更多内容。
因此,如果 UAC 确实妨碍您,唯一的方法就是禁用它(控制面板 -> 用户和帐户设置 -> 用户帐户控制,然后拖动在 Windows 7 上滑块滑至底部)。
Short answer was given above: no, you can't.
If you're interested in knowing why, read the following:
There is no way to 'automate' UAC. User Account Control was developed in order for malicious software (viruses, spyware, adware, etc...) to avoid being run on a target machine.
It is similar to the permission dialog on *nix-based Systems (Mac OS X, and many, many Linux distros), that ask for your password whenever they need to execute some code that requires an elevation of privileges (for example, installing an application).
The problem with Windows is that in previous versions (Windows XP), it became extremely easy for unwanted software to execute code on a target machine and compromise the whole system. This was put in place so users know when someone/something wants access to more than they can usually do by default.
So if UAC is really in your way, they only way is to disable it (Control Panel -> User and Account Settings -> User Account Control, and drag the slider to the bottom on Windows 7).