code_junkie

Launching a Application (.EXE) from C#?

Nov 11th, 2011
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. System.Diagnostics.Process.Start("PathToExe.exe");
  2.  
  3. using System.Diagnostics;
  4.  
  5. // Prepare the process to run
  6. ProcessStartInfo start = new ProcessStartInfo();
  7. // Enter in the command line arguments, everything you would enter after the executable name itself
  8. start.Arguments = arguments;
  9. // Enter the executable to run, including the complete path
  10. start.FileName = ExeName;
  11. // Do you want to show a console window?
  12. start.WindowStyle = ProcessWindowStyle.Hidden;
  13. start.CreateNoWindow = true;
  14.  
  15. // Run the external process & wait for it to finish
  16. using (Process proc = Process.Start(start))
  17. {
  18. proc.WaitForExit();
  19.  
  20. // Retrieve the app's exit code
  21. exitCode = proc.ExitCode;
  22. }
  23.  
  24. System.Diagnostics.Process.Start( @"C:WindowsSystem32Notepad.exe" );
Add Comment
Please, Sign In to add comment