开发者

call exe program in C#

开发者 https://www.devze.com 2022-12-30 11:50 出处:网络
H开发者_StackOverflow中文版ow to call an exe, generated from one c# file,from another c# file?using System.Diagnostics;

H开发者_StackOverflow中文版ow to call an exe, generated from one c# file, from another c# file?


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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消