3


I have a VB question for you, and although I've seen somewhat similar questions asked before, mine has a bit of a twist to it. I would like to know if it is possible to read each line of output from an external program running in CMD.exe which was launched with VB. Here's the twist: I would like to read this information while the external program is still running, NOT ONCE IT HAS COMPLETED.

I may be confused as to what consitutes "output", so let me give an example for those with more knowledge to guide me.

In my VB program suppose I pass this command to the CMD.exe:
someprogram.exe -param1 ABCD -param2 1234

Now suppose someprogram.exe launches, and as it does its job the following appaers in CMD:
Output line 1
Output line 2
Output line 3
...

While someprogram.exe is still running, I would like to read each of the above output lines (if that is the correct term) so that my VB program can summarize this information to the user. I've seen examples using commandexecutor and others using Environment.GetCommandLineArgs but every example I see is to read output once the external program has already ended.

Is it possible to do what I'm asking in VB?

1 Answers1

1

If your application initiates the process using Process.Start, you should be able to intercept the output stream by setting the RedirectStandardOuput on the ProcessInfo and reading the resulting stream. See this post for a c# sample.

Community
  • 1
  • 1
Jim Wooley
  • 10,169
  • 1
  • 25
  • 43