开发者

How can I call a batch file(.bat) in c#?

How c开发者_如何转开发an I call a batch file(.bat) in c#?


See Execute Commands From C#

public static int ExecuteCommand(string Command, int Timeout)
{
    int exitCode;
    var processInfo = new ProcessStartInfo("cmd.exe", "/C " + Command);
    processInfo.CreateNoWindow = true;
    processInfo.UseShellExecute = false;
    Process process = Process.Start(processInfo);
    process.WaitForExit(Timeout);
    exitCode = process.ExitCode;
    process.Close();
    return exitCode;
}


Use Process.Start("cmd.exe", pathToBat);.


Use Process.Start:

Process.Start("path to batch file");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜