<job>
<script language="VBScript">
Option Explicit
On Error Resume Next
Dim WshShell
set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
WScript.Sleep 1000
WshShell.SendKeys "telnet 174.24.2.155 23"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 5000
WshShell.SendKeys "User + {Enter}"
WScript.Sleep 5000
WshShell.SendKeys "User + {Enter}"
WScript.Sleep 4000
WshShell.SendKeys "Password"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 4000
WshShell.SendKeys "ACCT# + {Enter}"
WScript.Sleep 4000
WshShell.SendKeys "DBSPROCB + {Enter}"
WScript.Sleep 4000
WshShell.SendKeys "SUB + {Enter}"
WScript.Sleep 4000
WshShell.SendKeys "User.RUN.TEST1 + {Enter}"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 4000
WshShell.SendKeys "logoff + {Enter}"
WScript.Sleep 5000
WshShell.SendKeys "exit"
WshShell.SendKeys ("{Enter}")
WScript.Quit
</script>
</job>
After submitting batch job User.RUN.TEST1 from this VBscript we will get an message which is populated from system. Message is "Batch has been submitted successfully". I would like to trap this message in my script and would like to display it using Wscript.echo , Hence anyone could help me on this?
You can use stdout.ReadLine
:
Dim objShell
Dim objExec
Dim strFromProc
Dim strOutput
Set objShell = WScript.CreateObject("WScript.Shell")
Set objExec = objShell.Exec("cmd.exe /c dir")
' Read output line by line
Do While Not objExec.Stdout.atEndOfStream
strFromProc = objExec.StdOut.ReadLine()
strOutput = strOutput & vbCrLf & strFromProc
Loop
WScript.Echo "Output: " & strOutput