I am launching a process and attempting to read the StdOut... I am very familiar with the normal way of launching a process, redirecting, and capturing the output.
However, I have run across an app which I can launch manually at the command prompt and see output in the console, but does not provide any output on the StdOut or StdErr streams. I have attempted launching cmd.exe first and I am able to capture the Output from cmd.exe, but not this process when launched that way either.
To be more clear, when I run app.exe manually, I see this on the console:
Trying to connect to VP
Trying to connect to VP
When I launch it from System.Diagnostics.Process directly:
[blank]
When I launch it from System.Diagnostics.Process via cmd.exe:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
Again, the class I am using to do this runs many process and has only has an issue getting the output with this app.exe, so this is not a "hey maybe try redirecting the standard output" type of problem. I know that works in my implementation.
Ideas? I've simply never encountered this before.. How can a process put something on the console window when running manually, but not when running via the Process object?
Here's my code:
process = new Process();
process.StartInfo.FileName = f.FullName;
process.StartInfo.Arguments = arguments;
process.StartInfo.WorkingDirectory = workingDir;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.OutputDataReceived += p_OutputDataReceived;
process.ErrorDataReceived += p_ErrorDataReceived;
if (!process.Start())
{
throw new Exception("Failed to start [" + f.Name + "]. Exit code " + process.ExitCode);
}
process.BeginOutputReadLine();
process.BeginErrorReadLine();
processRunning = true;
process.WaitForExit();
exitCode = process.ExitCode;