|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Redirecting standard outputI want to run an application and capture its standard output. But the following code does not generate any output. Can anyone see something wrong? Public Sub RunApp(ByVal myprocess As String, ByVal param As String, ByVal workingDir As String) Dim p As Process = New Process() Dim psi As New ProcessStartInfo() psi.FileName = myprocess psi.WorkingDirectory = workingDir psi.Arguments = param psi.UseShellExecute = False psi.CreateNoWindow = True psi.RedirectStandardOutput = True psi.RedirectStandardInput = True psi.RedirectStandardError = True p.StartInfo = psi p.Start() AppendLine(p.StandardOutput.ReadToEnd) p.WaitForExit() End Sub ----------- Then I call the sub like below. RunApp("c:\auunitdel.exe", "-d", "") Thanks... mhmtz***@gmail.com wrote:
> I want to run an application and capture its standard output. But the The program almost certainly /is/ creating some output - you're just not > following code does not generate any output. Can anyone see something > wrong? > p.Start() > AppendLine(p.StandardOutput.ReadToEnd) > p.WaitForExit() waiting for the program to finish before reading the output that it hasn't had time to create yet. Swap the last two lines around, as in p.Start() p.WaitForExit() AppendLine(p.StandardOutput.ReadToEnd) HTH, Phill W. Phill,
I have tried that but still does not work. Phill W. yazdi: Show quoteHide quote > mhmtz***@gmail.com wrote: > > > I want to run an application and capture its standard output. But the > > following code does not generate any output. Can anyone see something > > wrong? > > p.Start() > > AppendLine(p.StandardOutput.ReadToEnd) > > p.WaitForExit() > > The program almost certainly /is/ creating some output - you're just not > waiting for the program to finish before reading the output that it > hasn't had time to create yet. > > Swap the last two lines around, as in > > p.Start() > p.WaitForExit() > AppendLine(p.StandardOutput.ReadToEnd) > > HTH, > Phill W. mhmtz***@gmail.com wrote:
Show quoteHide quote > Hi, I think you will have to set up a stream reader to read the output of> > I want to run an application and capture its standard output. But the > following code does not generate any output. Can anyone see something > wrong? > > > Public Sub RunApp(ByVal myprocess As String, ByVal param As String, > ByVal workingDir As String) > > Dim p As Process = New Process() > Dim psi As New ProcessStartInfo() > psi.FileName = myprocess > psi.WorkingDirectory = workingDir > psi.Arguments = param > psi.UseShellExecute = False > psi.CreateNoWindow = True > psi.RedirectStandardOutput = True > psi.RedirectStandardInput = True > psi.RedirectStandardError = True > p.StartInfo = psi > p.Start() > > > AppendLine(p.StandardOutput.ReadToEnd) > > p.WaitForExit() > > End Sub > > > ----------- > > Then I call the sub like below. > > RunApp("c:\auunitdel.exe", "-d", "") the process.
how to get both old and new value for a changed text box
check username and password in database How to make stacktrace include linenumber for release compiles? REPLACE method: unwanted multiple-replacement How can I create a Shortcut (with parameters) on a user-desktop with vb.net? how to run the execuatable before windows shutting down Detect right-click in MDI container's client area? word length occurance in a text.. Posting login data with HttpWebRequest How to re-start application? |
|||||||||||||||||||||||