1

I understand how to redirect StandardIO streams from Process objects in C# in general. However, I have to use ShellExecute for a particular command to work.

Consequently, I am unable to redirect these streams which I need for logging purposes.

I've tried redirecting it like this:

procStart.FileName = m1g;
procStart.Arguments = ">> output.txt";

At which point I plan on just reading the text file back, but this doesn't seem to work.

Is it possible to do something like this?

1 Answer 1

3

Pipe commands are implemented by cmd.exe. So you need to run cmd /c and add your executable path as argument

Process.Start("cmd.exe", "/c " + yourexecutablecommandline + " >> output.txt" ); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.