我怎么能叫在C#中的批处理文件(.bat)? [英] How can I call a batch file(.bat) in c#?
本文介绍了我怎么能叫在C#中的批处理文件(.bat)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何可以调用在C#中的批处理文件(.bat)
How can I call a batch file(.bat) in c#?
推荐答案
请参阅的执行命令,从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;
}
这篇关于我怎么能叫在C#中的批处理文件(.bat)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文