我正在尝试在运行以下代码的HTA中构建一些Subs。该脚本可以作为独立的WSH脚本正常工作,但是当我将代码放入HTA中的子代码时,它就变成了BERZERK。我的命令窗口出现了很多次,我认为它是为每个WshShell.Sendkeys启动一个新进程。我尝试了很多东西,但显然缺少一些东西。即使我在外部使用HTA调用脚本我也会得到相同的古怪行为,但是我可以在wsh脚本中运行它并且它工作正常......
请帮助!!
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