//执行bat批处理
public static void Main()
{
ProcessStartInfo myBat = new ProcessStartInfo()
{
FileName = "D:\\temp\\myBat.bat",
WorkingDirectory = Directory.GetCurrentDirectory(),
UseShellExecute = false
};
Process.Start(myBat).WaitForExit();
}
//批处理文件创建
public void WriteBatFile(string filePath, string fileContent)
{
File.Delete(filePath);
FileStream fs1 = new FileStream(filePath, FileMode.Create, FileAccess.Write);//创建写入文件
StreamWriter sw = new StreamWriter(fs1);
sw.WriteLine(fileContent);//开始写入值
sw.Close();
fs1.Close();
}