[c#] Run an exe from C# code

I have an exe file reference in my C# project. How do I invoke that exe from my code?

This question is related to c# .net

The answer is



Example:

System.Diagnostics.Process.Start("mspaint.exe");

Compiling the Code

Copy the code and paste it into the Main method of a console application. Replace "mspaint.exe" with the path to the application you want to run.


I know this is well answered, but if you're interested, I wrote a library that makes executing commands much easier.

Check it out here: https://github.com/twitchax/Sheller.


Example:

Process process = Process.Start(@"Data\myApp.exe");
int id = process.Id;
Process tempProc = Process.GetProcessById(id);
this.Visible = false;
tempProc.WaitForExit();
this.Visible = true;