尝试获取值并保存在 Dim 变量上时发送密钥的 VBS 问题



我需要一些VBS脚本的帮助。我想使用 VBS 脚本通过 telnet 访问路由器,并将路由器上的参数值保存到 Dim 变量中。

问题是 DIM 变量不保存路由器参数的输出。

这是我的脚本:

option explicit
DIM x
Set oShell = CreateObject("WScript.Shell")
oShell.run "cmd.exe"
WScript.Sleep 500
oShell.SendKeys "telnet 192.168.1.254"
oShell.SendKeys ("{Enter}")
WScript.Sleep 500
oShell.SendKeys "Administrator"
oShell.SendKeys ("{Enter}")
WScript.Sleep 500
oShell.SendKeys ""
oShell.SendKeys ("{Enter}")
WScript.Sleep 500
x = oShell.SendKeys ("env get var=_SW_FLAG") and oShell.SendKeys ("{Enter}") 
WScript.Sleep 500
oShell.SendKeys "exit"
oShell.SendKeys ("{Enter}")
WScript.Sleep 500
oShell.SendKeys "exit"
oShell.SendKeys ("{Enter}")
WScript.Sleep 500
MsgBox "The value of the parameter is:" & x

像这样的线程让我认为,使用您拥有的方法无法实现获取输出的特定细节。

我能得到的最接近的是这个之前问过的问题:vbs 记录 (.txt) telnet 输出

最新更新