Launching an application (.EXE) from C#?


How can I launch an application using C#?

Requirements: Must work on Windows XP and Windows Vista.

I have seen a sample from sampler that only works in Windows Vista.

9/22/2016 10:04:12 PM

Accepted Answer

Use System.Diagnostics.Process.Start() method.

Check out this article on how to use it.

10/27/2008 2:58:40 PM

Here's a snippet of helpful code:

using System.Diagnostics;

// Prepare the process to run
ProcessStartInfo start = new ProcessStartInfo();
// Enter in the command line arguments, everything you would enter after the executable name itself
start.Arguments = arguments; 
// Enter the executable to run, including the complete path
start.FileName = ExeName;
// Do you want to show a console window?
start.WindowStyle = ProcessWindowStyle.Hidden;
start.CreateNoWindow = true;
int exitCode;

// Run the external process & wait for it to finish
using (Process proc = Process.Start(start))

     // Retrieve the app's exit code
     exitCode = proc.ExitCode;

There is much more you can do with these objects, you should read the documentation: ProcessStartInfo, Process.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow