我需要一些有关 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