c#運行批処理文件
主要的方法就是運用process類,它可以運行exe文件,cmd等的進程,在這裡我是用來運行我的.bat文件,以下是我在一個項目中使用到的方法:
//name bat文件名,path bat路逕
public static boolean RunBat(string name,string path)
{
Process pro =new Process();
ProcessStartInfo pro_s =new ProcessStartInfo();
pro_s.FileName=name;
pro_s.WorkingDirectory=path;
pro_s.Arguments="10";//??
pro_s.UseShellExecute=false; //
pro_s.CreateNoWindow=false;
pro_s.RedirectStandardOutput = true;
pro_s.RedirectStandardError = true;
pro.StartInfo=pro_s;
pro.Start();
pro.WaitForExit();
return true;
}
0條評論