public LightSyncCmd(OnCmdExitHandler handler1) { exitHandler = handler1; p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived); p.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived); p.StartInfo.WorkingDirectory = System.Environment.CurrentDirectory; //设定程序名 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; }
public static void Run(string cmd, OnCmdExitHandler handler) { new LightSyncCmd(handler).run(cmd); }