//运行一个cmd命令
public static string RunCmd(string command)//command dos命令 { Process p = new Process(); p.StartInfo.WorkingDirectory = "c:\\"; p.StartInfo.FileName = "cmd.exe"; //程序名 p.StartInfo.Arguments = "/c " + command; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; //重定向错误输出 p.StartInfo.CreateNoWindow = true; //不显示窗口 p.Start(); return p.StandardOutput.ReadToEnd(); }