1 void ExecuteCmd(string dir, string cmd) 2 { 3 var process = new System.Diagnostics.Process(); 4 process.StartInfo.FileName = "cmd.exe"; 5 process.StartInfo.UseShellExecute = false; 6 process.StartInfo.RedirectStandardInput = true; 7 process.StartInfo.RedirectStandardOutput = true; 8 process.StartInfo.RedirectStandardError = true; 9 process.StartInfo.CreateNoWindow = true; 10 process.StartInfo.WorkingDirectory = dir; 11 process.StartInfo.Arguments = cmd; 12 process.Start(); 13 process.StandardInput.WriteLine(cmd); 14 process.StandardInput.WriteLine("exit"); 15 process.WaitForExit(); 16 process.Close(); 17 }
标签:exe,C#,cmd,process,WriteLine,StartInfo,NET,true From: https://www.cnblogs.com/baymaxwh/p/17377983.html