Running .exe Application from Windows Forms

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

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

I want to create a Windows form application in which the user can specify the location of the executable file, as well as the header file, so that the Windows form can do this for him, and the user would not need to go to the command line and do it.

I am very new to C #, so can anyone help me? Thank!

+5
source share
3 answers

You need to use a class Process:

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 infer these names / arguments from text fields.

+20
source

:

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

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

Process.Start(startInfo);
+4

https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.useshellexecute.aspx

This link will provide you with complete information about the Info .exe file.

another way that I used

ProcessStartInfo objProcess = new ProcessStartInfo(@"Yours .exe path");
objProcess.UseShellExecute = false;
objProcess.RedirectStandardOutput = true;
Process.Start(objProcess);

and it works great.

0
source

All Articles