Advertisement
kyrathasoft

capture redirected output from a process

May 22nd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. using System; using System.Diagnostics;
  2.  
  3. namespace LaunchAndCaptureOutput{
  4.  
  5. class Lacout{
  6. static void Main(){
  7. var proc = new Process{
  8. StartInfo = new ProcessStartInfo{
  9. FileName = @"C:\csdev\lessons\lessonette7\hello.exe",
  10. UseShellExecute = false,
  11. RedirectStandardOutput = true,
  12. CreateNoWindow = true
  13. }
  14. };
  15. proc.Start();
  16. string p = proc.StandardOutput.ReadToEnd();
  17. proc.WaitForExit();
  18. Console.WriteLine("Captured output: " + p);
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement