c#運行批処理文件,第1張

主要的方法就是運用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; 

}


生活常識_百科知識_各類知識大全»c#運行批処理文件

0條評論

    發表評論

    提供最優質的資源集郃

    立即查看了解詳情