Process standard output

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
 
M

Matt Burland

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top