C# 如何执行bat文件 传参数

C# 如何执行bat文件 传参数

分类: C# basic
[c-sharp] view plaincopy
  1. Process p = new Process();  
  2. string path = ...;//bat路径  
  3. ProcessStartInfo  pi= new ProcessStartInfo(path, ...);//第二个参数为传入的参数,string类型以空格分隔各个参数  
  4. pi.UseShellExecute = false;  
  5. pi.RedirectStandardOutput = true;  
  6. p.StartInfo = pi;  
  7. p.Start();  
  8. p.WaitForExit();  
  9. string output = p.StandardOutput.ReadToEnd();  

bat文件的内容为

  1. echo %1  %2  %3  
  2. pause 
原文地址:https://www.cnblogs.com/joean/p/4870486.html