一、执行cmd命令
/// <summary>
/// 执行cmd命令
/// </summary>
/// <param name="workingDirectory">要启动的进程目录</param>
/// <param name="command">要执行的命令</param>
public string StartCmd(string workingDirectory, string command)
{
string strOutput = "";
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/C" + command;// "/c"标示执行完命令后退出
p.StartInfo.WorkingDirectory = workingDirectory;
p.StartInfo.UseShellExecute = false;//不启用shell 启动进程
p.StartInfo.RedirectStandardInput = true;//重定向输入
p.StartInfo.RedirectStandardOutput = true;//重定向标准输出
p.StartInfo.RedirectStandardError = true;//重定向错误输出
p.StartInfo.CreateNoWindow = true;//不创建新窗口