听说CSDN牛人多,特来求助....
C#执行DOS
网上给的代码都是执行一条命令就退出进程:
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
p.Start();
p.StandardInput.WriteLine(strOdbc);
p.StandardInput.WriteLine("exit");
string strRst = p.StandardOutput.ReadToEnd();
p.Close();
但没有执行两条的,有的话也是做成BAT...
我现在想做个程序,能执行多条命令,命令由一个TEXTBOX给出(也就是说命令是不定的);该怎么做呢?
我想了,让P不CLOSE();但执行一条命令后程序就死了,所以来求助?