I have asked a similar question elsewhere but perhaps I did not ask it the right way or I was not clear enough so I am asking again.
This is where I want to get:
- Open a windows command prompt
- Run a DOS application through a dos command
- Read the returned text that is shown in the dos box and show it in a text box in my windows form. This needs to be repeated at regular intervals (say, every second) and the dos box should not be closed.
I have been going round in circles trying to use the Process and StartInfo commands, but they only run the application and close the process right away. I need to keep the dos box open and keep reading any new text that is added to it by the dos application. I also came across this thread that seems to answer my problem, but it is to in C# and I could not convert it:
Read Windows Command Prompt STDOUT
I did get to the part where I open the command prompt and get the application started, but I don't know how to read the data that it returns to the dos box console every now and then. I want to constantly check for changes so that I can act on them, perhaps using a timer control.
Please help.
Thanks!
I ran the code that was kindly provided by Stevedog and used it like this:
Private WithEvents _commandExecutor As New CommandExecutor()
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
_commandExecutor.Execute("c:\progra~2\zbar\bin\zbarcam.exe", "")
End Sub
Private Sub _commandExecutor_OutputRead(ByVal output As String) Handles _commandExecutor.OutputRead
txtResult.Text = output
End Sub
But all I am getting is blank dos box. The zbarcam application runs properly because I can see the camera preview and I can also see it detecting QR Codes, but the text is not showing in the dos box and _commandExecutor_OutputRead
sub is not being triggered unless I close the DOS box.