Hello, :)
I'm currently writing a frontend for a console application using VB .net.
I'm using the traditional Process creation to launch it and redirect input
and output to my windows application, something like this :
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.CreateNoWindow = True
myProcess.StartInfo.RedirectStandardInput = True
myProcess.StartInfo.RedirectStandardOutput = True
myProcess.StartInfo.RedirectStandardError = True
myProcess.Start()
I then read the console application output and store it into a RichTextBox
using a separate thread :
Sub MonitorPaupOutput()
Dim t As String
frmMain.DefInstance.rtfLog.SelectionStart =
Len(frmMain.DefInstance.rtfLog.Text)
Do
t = sOut.ReadLine()
If t <> "" Then
frmMain.DefInstance.rtfLog.SelectedText = t + vbCrLf
frmMain.DefInstance.rtfLog.ScrollToCaret()
End If
System.Windows.Forms.Application.DoEvents()
Loop
End Sub
If I run the console application in non-interactive mode (i.e. the dos
application only displays some results then quits), everything works fine, I
get all the output. But if I use the console app in interactive mode (like a
standard DOS box, where you have to enter commands), I get only partial
outputs. I have to send a new command to get the end of the previous output,
+ a part of the new.
Let's take an example. I have a frontend for a "cmd.exe" process. I then
send "dir c:\" using the following command :
sIn.Write("dir c:\" & System.Environment.NewLine)
("sIn" is my input streamwriter redirector)
Then I get about half of my directory listing. I send "Dir C:\" again, and I
get the rest of my first "dir" command, and the first half of the second
one... And so on...
It seems that when a prompt in the console app occurs, it blocks the output
until a new command is entered. I'm really stuck here, since I need to be
able to fully control my console app and get all the output I can.
For those interested, and for the kind souls whe would like to help, you'll
find an example here : http://chezpoupoune.free.fr/temp/RedirectConsole.zip.
I'm not the author, but it illustrates well this problem on a cmd.exe front
end.
No need to say that I'll be really grateful to anyone who will try to help.
Thank you very much for your assistance !
Best regards,
F.C