C# 执行bat批处理文件的小例子。
Process pro = new Process();
FileInfo file = new FileInfo(batPath);
pro.StartInfo.WorkingDirectory = file.Directory.FullName;
pro.StartInfo.FileName = batPath;
pro.StartInfo.CreateNoWindow = false;
pro.Start();
pro.WaitForExit();
}
代码:
private void RunBat(string batPath)
{Process pro = new Process();
FileInfo file = new FileInfo(batPath);
pro.StartInfo.WorkingDirectory = file.Directory.FullName;
pro.StartInfo.FileName = batPath;
pro.StartInfo.CreateNoWindow = false;
pro.Start();
pro.WaitForExit();
}
本文介绍了一个使用C#代码执行bat批处理文件的简单实例,展示了如何通过Process类来启动并等待批处理文件执行完成。

1918

被折叠的 条评论
为什么被折叠?



