110,536
社区成员
发帖
与我相关
我的任务
分享
Process p = new Process();
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "ConsoleApplication4.exe"; //你的bat
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;//这是你要的主要的redirect
info.UseShellExecute = false;//必须false
info.CreateNoWindow = false;
p.StartInfo = info;
p.Start();
p.WaitForExit();//等待与否看你的需求
StreamWriter sw = new StreamWriter("C:\\Redirect.txt");
sw.Write(p.StandardOutput.ReadToEnd());
sw.Close();
Process p = new Process();
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "ConsoleApplication4.exe"; //你的bat
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;//这是你要的主要的redirect
info.UseShellExecute = false;//必须false
info.CreateNoWindow = false;
p.StartInfo = info;
p.Start();
p.WaitForExit();//等待与否看你的需求
StreamWriter sw = new StreamWriter("C:\\Redirect.txt");
sw.Write(p.StandardOutput.ReadToEnd());
sw.Close();