Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you execute another EXE file from within a C# console application?

Can you execute another EXE file from within a C# console application?

  • Can you pass arguments?
  • Can you get the exit code back?
like image 763
Lieven Cardoen Avatar asked Dec 02 '09 13:12

Lieven Cardoen


People also ask

How can I run an EXE file from my C# code?

FileName = "dcm2jpg.exe"; startInfo. WindowStyle = ProcessWindowStyle. Hidden; startInfo. Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2; try { // Start the process with the info we specified. // Call WaitForExit and then the using statement will close.

Can C# be compiled to exe?

After a developer writes the C# code, he or she compiles their code. This results in Common Intermediate Language stored within Portable Executable (PE for 32-bit, PE+ for 64-bit) files such as “.exe” and “. dll” files for Windows. These files are distributed to users.

What does exe stand for in computer terms?

An executable file (EXE file) is a computer file that contains an encoded sequence of instructions that the system can execute directly when the user clicks the file icon.


1 Answers

Like this:

        var proc = new Process();         proc.StartInfo.FileName = "something.exe";         proc.StartInfo.Arguments = "-v -s -a";         proc.Start();         proc.WaitForExit();         var exitCode = proc.ExitCode;         proc.Close(); 
like image 100
Jonas Lincoln Avatar answered Sep 22 '22 00:09

Jonas Lincoln