C# 调用可执行exe文件几种方法小结

时间:2025-01-25 08:55:59

1.利用进程池方式启动

string exefile = "";
if ((exefile)) {
    Process process = new Process(); // params 为 string 类型的参数,多个参数以空格分隔,如果某个参数为空,可以传入””
    ProcessStartInfo startInfo = new ProcessStartInfo(exefile, params);
     = startInfo;
    ();
}

2.遮蔽CLI启动窗口

string exefile = "";
if ((exefile)) {
    Process process = new Process();
    ProcessStartInfo startInfo = new ProcessStartInfo(exefile, path);
     = false;
     = true;     = true;
     = startInfo;
    ();
    (2000);
    string output = ();
    rtb_analyze.Text = output;
    ();         
}

3.异步启动方式

public void exec(string exePath, string parameters)
{
    Process process = new ();
     = exePath;
     = parameters;
     = false;
     = true;
     = true;
    ();
    ();
     += new  DataReceivedEventHandler(processOutputDataReceived);
}

资料参考地址:/epXmh