C# 如何执行bat文件 传参数
分类: C# basic 2011-04-25 18:55 3972人阅读 评论(0) 收藏 举报
[c-sharp] view plaincopy
- Process p = new Process();
- string path = ...;//bat路径
- ProcessStartInfo pi= new ProcessStartInfo(path, ...);//第二个参数为传入的参数,string类型以空格分隔各个参数
- pi.UseShellExecute = false;
- pi.RedirectStandardOutput = true;
- p.StartInfo = pi;
- p.Start();
- p.WaitForExit();
- string output = p.StandardOutput.ReadToEnd();
bat文件的内容为
[vb] view plaincopy
- echo %1 %2 %3
- pause
时间: 2024-12-21 10:23:57