ProcessStorm
New member
- Joined
- May 22, 2014
- Messages
- 2
- Programming Experience
- 3-5
Hey guys/fellow vb programmers,
Before we start:
- It is the first time I resort to starting a new thread in a forum to solve a programming issue.
- I did a research all over the web for this issue.
- I read thoroughly the MSDN documentation.
- I researched the forum for "process.StandardOutput" and the error itself.
I'm in the need to start and control a specific process (Robocopy.exe) which is executed in a second thread.
At some point I want the process.StandardOutputStream to be redirected to a textbox line by line.
Even by fallowing exactly the MSDN example, I still get the "StandardOut has not been redirected or the process hasn't started yet." error.
As you can see, my process.RedirectStandardOutput and the process.UseShellExecute are both correctly set.
Here is a part of my code:
I tried to get the StandardOutput several different ways using a variable or a streamReader and verifying that the process.HasExited was false before reading the output stream.
Here is a screenshot of the error happening on the bold/underlined line of code above.
If any other info is needed please let me know.
If anyone is willing to help me in resolving this mystery i would greatly appreciate.
Thanks,
ProcessStorm
Before we start:
- It is the first time I resort to starting a new thread in a forum to solve a programming issue.
- I did a research all over the web for this issue.
- I read thoroughly the MSDN documentation.
- I researched the forum for "process.StandardOutput" and the error itself.
I'm in the need to start and control a specific process (Robocopy.exe) which is executed in a second thread.
At some point I want the process.StandardOutputStream to be redirected to a textbox line by line.
Even by fallowing exactly the MSDN example, I still get the "StandardOut has not been redirected or the process hasn't started yet." error.
As you can see, my process.RedirectStandardOutput and the process.UseShellExecute are both correctly set.
Here is a part of my code:
VB.NET:
Dim ProcessProperties As New ProcessStartInfo
ProcessProperties.FileName = "robocopy.exe"
ProcessProperties.WindowStyle = ProcessWindowStyle.Hidden
ProcessProperties.CreateNoWindow = True
ProcessProperties.UseShellExecute = False
ProcessProperties.RedirectStandardOutput = True
ProcessProperties.StandardOutputEncoding = System.Text.Encoding.Default
Dim backupProcess As Process = Process.Start(ProcessProperties)
'StandardOutput.ReadToEnd needs to be called before the Process.WaitForExit otherwise the process will hang.
[B][U]Console.WriteLine(backupProcess.StandardOutput.ReadToEnd) [/U][/B]
backupProcess.WaitForExit()
I tried to get the StandardOutput several different ways using a variable or a streamReader and verifying that the process.HasExited was false before reading the output stream.
Here is a screenshot of the error happening on the bold/underlined line of code above.
If any other info is needed please let me know.
If anyone is willing to help me in resolving this mystery i would greatly appreciate.
Thanks,
ProcessStorm
Last edited: