Running a .exe application from Windows Forms

Retry picture Retry · Jul 24, 2012 · Viewed 32.2k times · Source

I have an application that I run on the command prompt as follows:

C:\some_location> "myapplication.exe" headerfile.h

I want to create a Windows Forms application where the user can specify the location of the executable and also the header file so that the Windows Forms application can do this for him/her, and the user wouldn't have to go to the command line and do it.

How can I do this?

Answer

Jaime Torres picture Jaime Torres · Jul 24, 2012

You need to use the Process class:

Process.Start(@"C:\some_location\myapplication.exe");

For arguments:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\some_location\myapplication.exe";
startInfo.Arguments = "header.h";
Process.Start(startInfo);

Obviously you can pull these names/arguments from text boxes.