Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. using System.Diagnostics;
  2.  
  3. Process p = new Process();
  4. p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
  5. p.StartInfo.FileName = processname;
  6. p.StartInfo.Arguments = arguments;
  7.  
  8. p.Start();
  9. p.WaitForExit()
  10.  
  11. public static void execute(string processname, string arguments) {
  12. Process p = new Process();
  13. p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
  14. p.StartInfo.FileName = processname;
  15. p.StartInfo.Arguments = arguments;
  16. p.StartInfo.UseShellExecute = false;
  17. p.StartInfo.RedirectStandardOutput = true;
  18. p.StartInfo.RedirectStandardError = true;
  19. p.Start();
  20. p.WaitForExit();
  21.  
  22. var stdout = p.StandardOutput.ReadToEnd();
  23. var stderr = p.StandardError.ReadToEnd();
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement