您的位置:首页 > 编程语言 > C#

C# 执行批处理文件

2009-05-28 18:11 274 查看
// System.Diagnostics.Process pr1 = System.Diagnostics.Process.Start("cmd", " /c ftpget.bat");
// pr1.StartInfo.CreateNoWindow = true;
// pr1.WaitForExit();
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("cmd.exe");

psi.UseShellExecute = false;

psi.RedirectStandardOutput = true;

//psi.RedirectStandardInput = true;

psi.RedirectStandardError = true;

psi.Arguments = "/c F://aa//ftpget.bat";

psi.WorkingDirectory = "F://aa//";

// Start the process

System.Diagnostics.Process proc = System.Diagnostics.Process.Start(psi);

// Attach the output for reading

System.IO.StreamReader sOut = proc.StandardOutput;

proc.Close();

// Read the sOut to a string.

string results = sOut.ReadToEnd().Trim();

sOut.Close();
Console.WriteLine(results);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: