I have created one batch file through which I am trying to create one .vbs file and place some command into that. But I am not able to transfer my all the command to the .vbs file.
@echo off
echo:
set /a i=1
:Loop
if %i% GTR 0 (
rem create temp vbs file
echo Dim IPAddress > temp.vbs
echo IPAddress="192.168.1.109" >> temp.vbs
echo SET WshShell = WScript.CreateObject("WScript.Shell"^) >> temp.vbs
echo WshShell.run("telnet.exe " &IPAddress) >> temp.vbs
echo WScript.Sleep 3000 >> temp.vbs
echo WshShell.SendKeys"qwert" >> temp.vbs
echo WshShell.SendKeys("{Enter}") >> temp.vbs
echo WScript.Sleep 3000 >> temp.vbs
echo WshShell.SendKeys"asdf123" >> temp.vbs
echo WshShell.SendKeys("{Enter}") >> temp.vbs
echo WScript.Sleep 1000 >> temp.vbs
echo ' Reboot Device >> temp.vbs
echo ' WshShell.SendKeys"reboot" >> temp.vbs
echo ' WshShell.SendKeys("{Enter}") >> temp.vbs
echo ' WScript.Sleep 1000 >> temp.vbs
echo strPath = WshShell.CurrentDirectory >> temp.vbs
echo ' Close telnet session >> temp.vbs
echo WshShell.Run "taskkill /im telnet.exe", , True >> temp.vbs
rem wscript C:\Users\guest\Desktop\temp.vbs
echo Reboot Count %i%
echo:
set /a i+=1
Timeout /t 90 >nul
GOTO Loop
) ELSE (
echo Out of if loop
)
Following is the Actual output of the temp.vbs file
WshShell.run("telnet.exe "
WScript.Sleep 3000
WshShell.SendKeys"qwert"
WshShell.SendKeys("{Enter}")
WScript.Sleep 3000
WshShell.SendKeys"asdf123"
WshShell.SendKeys("{Enter}")
WScript.Sleep 1000
' Reboot Device
' WshShell.SendKeys"reboot"
' WshShell.SendKeys("{Enter}")
' WScript.Sleep 1000
strPath = WshShell.CurrentDirectory
' Close telnet session
WshShell.Run "taskkill /im telnet.exe", , True
Expected output of temp.vbs file
Dim IPAddress
IPAddress="192.168.1.109"
SET WshShell = WScript.CreateObject("WScript.Shell"^)
WshShell.run("telnet.exe " &IPAddress)
WScript.Sleep 3000
WshShell.SendKeys"qwert"
WshShell.SendKeys("{Enter}")
WScript.Sleep 3000
WshShell.SendKeys"asdf123"
WshShell.SendKeys("{Enter}")
WScript.Sleep 1000
' Reboot Device
' WshShell.SendKeys"reboot"
' WshShell.SendKeys("{Enter}")
' WScript.Sleep 1000
strPath = WshShell.CurrentDirectory
' Close telnet session
WshShell.Run "taskkill /im telnet.exe", , True
Kindly help me on this to achieve this scenario.
Thank your very much in advance.