Date: Fri, 24 May 2013 01:11:20 +0200
Quote:
- The Official Scripting Guys Forum! Forum (recent threads)
Communicating with cmd
http://services.social.microsoft.com/feeds/FeedItem?feedId=00000000-0000-0000-0000-000000000000&itemId=946e58cc-7226-4e18-b74a-25aca6eb2887&title=Communicating+with+cmd&uri=http%3a%2f%2fsocial.technet.microsoft.com%2fForums%2fen-US%2fITCG%2fthread%2f946e58cc-7226-4e18-b74a-25aca6eb2887%2f&k=fSGkXBrwArim9uTth1nPoeeYsdoeYwP9D%2bgmm7vKLhs%3d
Text:
I would like to interact with the .cmd window via .Exec and Stdin and Stdout. How can I issue multiple commands to the same .cmd window/session? I don't want to do it by tieing a long string of &'s together.
My current code is below:
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")
'The tool is launched
'Set oExec = WshShell.Exec("cmd /c dir C:\backup_Restore & ls")
Set oExec = WshShell.Exec("cmd /c dir C:\backup_Restore")
Set oExec = oExec & WshShell.Exec("cmd /c ls")
Set oExec = oExec & WshShell.Exec("cmd /c cd C:\CME")
Set oExec = oExec & WshShell.Exec("cmd /c ls")
'We wait for the end of process
Do While oExec.Status = 0
WScript.Sleep 100
Loop
'We scan and display the command output flow
Do While oExec.StdOut.AtEndOfStream <> True
totalline = totalline & oExec.StdOut.ReadLine & vbcrlf
Loop
Wscript.echo totallineVia FeedShow.com