Calling exe program in c #

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

+2


a source to share


3 answers


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();
}

      



+3


a source


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



+1


a source


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

You can find examples of each of the links provided.

0


a source







All Articles