C# 执行bat批处理文件

 

1 ///batPath为.bat 可执行文件的绝对路径
 2 private void RunBat(string batPath)
 3 {
 4 Process pro = new Process(); 
 5 FileInfo file = new FileInfo(batPath);
 6 pro.StartInfo.WorkingDirectory = file.Directory.FullName;
 7 pro.StartInfo.FileName = batPath;
 8 pro.StartInfo.CreateNoWindow = True;//隐藏窗体的显示
 9 pro.Start();
10 pro.WaitForExit();
11 }