【发布时间】:2023-01-12 10:23:23
【问题描述】:
我有一个 vbscript,它通过以下方式在管理模式下生成 powershell:
Set oShell = CreateObject("Shell.Application")
oShell.ShellExecute "powershell", "-executionpolicy bypass", "", "runas", 1
然后我尝试通过以下方式发送密钥:
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.sleep 2000
WshShell.sendkeys "hello"
由于键不起作用,我尝试将后一部分分离到一个单独的文件中,并专门在 PID 上执行了 WshShell.AppActivate 以确保它在发送键之前获得正确的窗口焦点,但它仍然不会发送字符串。
相反,如果我不在管理员中运行 powershell,一切正常:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run "powershell"
WScript.sleep 200
WshShell.sendkeys "cls"
有人可以告诉我我做错了什么吗?
【问题讨论】:
标签: powershell vbscript