I have a batch file that contain:
@echo off
start telnet x.x.x.x 5000
cscript script_test.vbs
while script_test.vbs contains:
set OBJECT=WScript.CreateObject("WScript.Shell")
WScript.sleep 50
'Enter username
OBJECT.SendKeys "xxxx{ENTER}"
'Enter password
WScript.sleep 1000
OBJECT.SendKeys"xxxx{ENTER}"
WScript.sleep 1000
'First Command
OBJECT.SendKeys"COMMAND1 {ENTER}"
WScript.sleep 100
OBJECT.SendKeys " "
Noting that COMMAND1 will result an output that I need to save in a file.
How to save the output resulting from this command to a specific file by specifying its path.
Do not use
SendKeys
for automating thetelnet
command that ships with Windows. Use atelnet
command that is actually scriptable, likeplink
from the PuTTY suite.