Process standard output

  • Thread starter Thread starter Veronica
  • Start date Start date
V

Veronica

Dim pr As New System.Diagnostics.Process()
Dim output as string

pr.StartInfo.FileName = "notepad.exe"
pr.StartInfo.UseShellExecute = False
pr.StartInfo.RedirectStandardOutput = True
pr.Start()
pr.WaitForExit()
Output = pr.StandardOutput.ReadToEnd

With the above code you should get on output variable
anything you wrote on notepad before you close it. I
couldn't make it works. Did I miss something? I read a lot
and I could'nt found an answer. Please I need the solution
or other source of information.

Thanks, Veronica
 
The problem might be that you need to read the StdOut before the WaitForExit
(this is explained in the MSDN documentation) otherwise the pipe can fill up
and hang both apps. What exactly is happening with your program? Is it
hanging or are you just getting nothing in Output?
 
Back
Top