Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. System.Diagnostics.Process process = new System.Diagnostics.Process();
  2. System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
  3.  
  4. startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
  5. startInfo.FileName = "cmd.exe";
  6. startInfo.Arguments = "/C SomeEXE inputfile.txt";
  7. startInfo.UseShellExecute = false;
  8. startInfo.RedirectStandardOutput = true;
  9.  
  10. process.StartInfo = startInfo;
  11. process.Start();
  12.  
  13. // Now use streams to capture the output
  14. StreamReader outputReader = process.StandardOutput;
  15.  
  16. process.WaitForExit();
  17.  
  18. String line = outputReader.ReadToEnd();
  19.  
  20. startInfo.FileName = "SomeEXE";
  21. startInfo.Arguments = "inputfile.txt";
  22.  
  23. myProcess.StartInfo.RedirectStandardInput = true;
  24. StreamWriter myStreamWriter = myProcess.StandardInput;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement