Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
// 这里是关键点,不用Shell启动/重定向输入/重定向输出/不显示窗口
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WorkingDirectory = "f:\\f";
string command = "cscript.exe";
p.StartInfo.Arguments = "c:\\windows\\system32\\iisapp.vbs /a \"DefaultAppPool\" " + command;
p.Start();
//p.StandardInput.WriteLine("cscript.exe c:\\windows\\system32\\iisapp.vbs /a \"DefaultAppPool\"");
//p.StandardInput.WriteLine("exit");
//p.WaitForExit(60000);
string s = p.StandardOutput.ReadToEnd();// 得到cmd.exe的输出
p.Close();