I need some help with a VBS script. I want use a VBS script to access a router via telnet and save the value of a parameter on the router to a Dim variable.
The problem is that the DIM variable doesn´t save the output of the router parameter.
This is my script:
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
Threads like this make me think that the particular detail of getting the output is not possible with the approach you have.
The closest I could get is this previously asked question: vbs to log (.txt) telnet output