2

How to call an exe, generated from one c# file, from another c# file?

andrew Sullivan
  • 3,944
  • 9
  • 31
  • 42
  • 1
    possible duplicate of [Launching a Application (.EXE) from C#?](http://stackoverflow.com/questions/240171/launching-a-application-exe-from-c) – James May 14 '10 at 09:51

3 Answers3

3
using System.Diagnostics;

string command = @"C:\tmp\myExe.exe -my -params";

ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command)
    {
        RedirectStandardOutput = true,
        UseShellExecute = false,
        CreateNoWindow = true
    };

using (Process proc = new Process())
{
    proc.StartInfo = procStartInfo;
    proc.Start();

    return proc.StandardOutput.ReadToEnd();
}
David Hedlund
  • 128,221
  • 31
  • 203
  • 222
1

System.Diagnostics.Process.Start("Path to any file, including exes");

Jouke van der Maas
  • 4,117
  • 2
  • 28
  • 35
0

If you want to generate the C# file before executing it you can use the CSharpCodeProvider to compile the C# file, and then use the Process class to execute the output file.

You can find examples of each in the provided links.

Patrick
  • 17,669
  • 6
  • 70
  • 85