C# 执行批处理文件
2008-05-22 16:31
197 查看
// 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);
// 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);
相关文章推荐
- C# 执行bat批处理文件
- C#执行批处理,当批处理不在程序根目录时,出现“找不到文件”的问题的解决方法
- C#中执行批处理文件(.bat),执行数据库相关操作
- c#中调用cmd命令执行批处理文件
- C# 执行批处理文件
- c#执行bat批处理文件,并通过线程将结果显示在控件中
- C#: 执行批处理文件(*.bat)的方法
- C#: 执行批处理文件(*.bat)的方法
- 使用C#创建WindowsService(Windows服务):定期执行Dos命令或Bat(批处理)文件
- (C#) 调用执行批处理文件
- C#: 执行批处理文件(*.bat)的方法
- C# 执行bat批处理文件
- C# 执行批处理文件(*.bat)的方法代码
- C#调用批处理(bat)文件,并获取执行批处理(bat)文件后返回值
- c# 执行批处理文件
- C# 执行bat批处理文件
- C#中执行批处理文件(*.bat)的方法代码
- C#执行批处理文件,重定向时发生的一场乌龙
- c#执行外部批处理(bat)文件
- C# 读取批处理文件(.bat)执行结果到程序显示