Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a .exe application from Windows Forms

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?

like image 778
Retry Avatar asked Jul 24 '12 17:07

Retry


People also ask

How do I create a setup EXE file in Windows Forms application?

Open Solution Explorer->Click on 'solution'test'('project)->Add New Project->Select other project types from left window->Select visual studio Installer->Select the setup Wizard-> write your setup name in below(mysetup)->click OK.

How do I run a single instance of the application using Windows Forms?

" This feature is already built in to Windows Forms. Just go to the project properties and click the "Single Instance Application" checkbox. "

Can you use Entity Framework with Windows Forms?

Perform CRUD Operations Using Entity Framework. First of all, create a Windows Forms App. To create a new app click on file menu > New > New project and select Windows Forms App then click on Next button. ProjectName - Enter your project name in this field.


2 Answers

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.

like image 117
Jaime Torres Avatar answered Oct 02 '22 15:10

Jaime Torres


You can try with this code:

ProcessStartInfo startInfo = new ProcessStartInfo("yourExecutable.exe");

startInfo.Arguments = "header.h"; // Your arguments

Process.Start(startInfo);
like image 45
Aghilas Yakoub Avatar answered Oct 02 '22 16:10

Aghilas Yakoub