CommandLine function not returning expected output

We recently came across an interesting issue in our CommandLine function where the output returned by the function did not match the output returned by the application that it executed (it was only a part of the output). The application that it was calling in this case, was a .NET console application that wrote a few thousand lines to the console.

Internally, we use the async read operations on the Process class to capture the output from the application. Something that we noticed was that everything worked correctly when we called process.WaitForExit(), but when calling process.WaitForExit(60000) (enough time for the called process to complete), it did not work correctly.

After using dotPeek to look at the Process code, we saw that the code (in WaitForExit) only waits for the output stream to finish if the timeout is set to -1 (infinite).

Thus, if you are using the CommandLine function and you do not get the full output from your application, change the “Timeout” property on the function to 0 (infinite) and it should work as expected.