Ich habe einen Code, der Schlüssel an Telnet sendet, um einen IR-Sender von mir zu manipulieren. Das Skript funktioniert gut als eigenständiges WSH-Skript, aber sobald ich versuche, es in ein Sub innerhalb eines HTA zu setzen, geht es an BERZERK. Anstatt meine Schlüssel an die erste Instanz von cmd zu senden, wird für jeden .sendkey ein neuer geöffnet!
Bitte helfen Sie!
Hier ist mein Standalone-Skript:
<job>
<script language="VBScript">
Option Explicit
On Error Resume Next
Dim WshShell
set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
WScript.Sleep 500
WshShell.SendKeys "telnet 130.160.176.219 4998"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 5000
WshShell.SendKeys "sendir,1:1,1,37764,1,1,340,168,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,22,21,64,21,22,21,64,21,22,21,22,21,22,21,22,21,64,21,22,21,64,21,22,21,64,21,64,21,64,21,64,21,4833"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500
WshShell.SendKeys "sendir,1:1,10,37764,1,1,340,168,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,22,21,22,21,22,21,22,21,64,21,22,21,22,21,22,21,64,21,64,21,64,21,64,21,22,21,64,21,4833"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500
WshShell.SendKeys "sendir,1:1,5,37764,1,1,340,168,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,22,21,64,21,22,21,22,21,22,21,22,21,22,21,22,21,64,21,22,21,64,21,64,21,64,21,64,21,64,21,4833"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500
WshShell.SendKeys "sendir,1:1,11,37764,1,1,340,168,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,22,21,64,21,64,21,64,21,64,21,22,21,64,21,22,21,64,21,22,21,22,21,22,21,22,21,64,21,22,21,64,21,4833"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 500
WshShell.SendKeys "sendir,1:1,1,37764,1,1,340,168,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,22,21,64,21,22,21,64,21,22,21,22,21,22,21,22,21,64,21,22,21,64,21,22,21,64,21,64,21,64,21,64,21,4833"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys ("^{]}q{Enter}exit{Enter}")
WScript.Quit
</script>
</job>
exec
anstelle von verwenden run
? Haben Sie die AppActivate
Methode vor dem Senden von Schlüsseln ausprobiert ? ( technet.microsoft.com/en-us/library/ee156605.aspx ) Beachten Sie, dass Sie mit AFAIK, exec auf Telnet-Antworten und -Aufforderungen antworten können