在 VbScript 中绕过 UAC
我有一个在用户注销时运行的 Vbscript,它应该关闭某个服务,但是我无法关闭该服务,因为它被 UAC 阻止了。我想知道是否有一种方法可以在我的 vbscript 中绕过 UAC,而不必在我的域中的每台计算机上关闭 UAC。 谢谢!
I have a Vbscript that runs on user log off that is suppose to turn off a service, however i't can't turn off the service since it's being blocked by UAC. I was wondering if there is a way to bypass UAC in my vbscript instead of having to turn off UAC on every machine in my domain.
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你可以通过说“它不应该适用于我”来绕过它,那么 UAC 的意义何在?您无法从 vbscript 绕过它。
不过,您可以通过管理方式执行此操作,首先使用提升的凭据运行脚本。
例如,通过“登录时”计划任务,以管理员或系统身份运行。我相信这适用于 Windows 7 和 Vista。
要在远程计算机上创建此类任务:
还可以使用脚本创建任务。
注意:如果这是脚本执行的唯一操作,您只需使用
SC
或NET STOP
等命令即可直接停止服务。What would be the point of UAC if you could bypass it by saying "it shouldn't apply to me"? You cannot bypass it from vbscript.
You can do this administratively though, by running the script using elevated credentials in the first place.
For example by having an "on logon" scheduled task, running as Administrator or SYSTEM. I believe this works in Windows 7, and vista.
To create such a task on a remote machine:
Tasks can also be created using script.
Note: If this is the only thing the script does, you can simply use a command like
SC
orNET STOP
to stop the service directly.确实不能从 vbscript 绕过它(据我所知以任何方式)。但 vbscript 是解决方案的一部分。
另一个稍微灵活的解决方案(丑陋但灵活)使用以下 2 行 vbscript:
该解决方案还需要以下自定义 xml 事件过滤器对于您的调度触发器:
以下 xml 是我的任务调度程序的导出(修改了主机名和用户 ID)。它运行管理员级别的 powershell 控制台
请注意,您可以根据需要对数据字符串进行选择性:
是否是您任意与想要的应用程序绑定的任何足够唯一的字符串以提升的权限运行。因此,您可以管理任何应用程序,而无需不断提醒 Windows 7 没问题。它真的不应该这么难:-(
It's quite true you cannot bypass it from vbscript (in any way that I know). But vbscript is part of the solution.
Another slightly more flexible solution (ugly but flexible) uses the following 2 lines of vbscript:
The solution also requires the following custom xml event filter for your scheduling trigger:
The following xml is an export from my task scheduler (with hostname and userid modified). It runs an admin level powershell console
Note that you can be as selective as necessary with the data string:
Is any sufficiently unique string that you arbitrarily tie to the app you want to run with elevated privileges. So, you can be admin on any app without constantly reminding windows 7 that it's ok. It really should never be this hard:-(