문제

I have noticed that SendKeys inside a VBScript does not work when the user is not logged in or the script is being executed as LOCAL SYSTEM.

Example:

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "telnet 192.168.1.50"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "some telnet command"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "another telnet command"
WshShell.SendKeys "{ENTER}"

Is there any other way to send keys to an application? SendInput does not seem to work in a .vbs file...

도움이 되었습니까?

해결책

Based on your constraints, this is what I would do:

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd"
WScript.Sleep 100 
WshShell.AppActivate "C:\Windows\system32\cmd.exe" 
WScript.Sleep 100 
WshShell.SendKeys "telnet 192.168.1.50"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "some telnet command"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "another telnet command"
WshShell.SendKeys "{ENTER}"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top