以完全隐藏的方式从 vbs 使用 SendKeys?

以完全隐藏的方式从 vbs 使用 SendKeys?

这是我计划做的事情

Set WshShell = WScript.CreateObject("WScript.Shell")    
WshShell.Run"cmd"
WshShell.AppActivate"telnet 192.168.1.1"     
WScript.Sleep 50    
WshShell.SendKeys"telnet 192.168.1.1 -f 22.txt{ENTER}" 
WScript.Sleep 2000    
WshShell.SendKeys "admin{ENTER}"     
WScript.sleep 50     
WshShell.SendKeys"sys info{ENTER}"   
WScript.Sleep 50

我想让它完全隐藏,但它只sendkeys在激活的窗口上起作用,因此尝试通过最小化窗口来隐藏它失败了。我找不到任何可以理解的方法来做到这一点

如果不采用额外的工具,这可能吗?

答案1

我发现的唯一解决方案是使用AutoIt 脚本语言

DllCall("kernel32.dll", "boolean", "Wow64DisableWow64FsRedirection", "boolean", 1) 
Run('cmd',"",@SW_HIDE) Local $hWnd = WinWait("[CLASS:cmd]", "", 1) 
Sleep (250) 
ControlSend("C:\WINDOWS\SYSTEM32\cmd.exe","","","telnet 192.168.1.1 -f log.txt{ENTER}") 
Sleep (2500) 
ControlSend("Telnet 192.168.1.1","","","pass1{ENTER}") 
ControlSend("Telnet 192.168.1.1","","","sysinfo{ENTER}") 
Sleep (1500) 
WinClose("Telnet 192.168.1.1")

相关内容