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?

ScottishTapWater
  • 3,656
  • 4
  • 38
  • 81

1 Answers1

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" ); 
Perfect28
  • 11,089
  • 3
  • 25
  • 45