C# 调用cmd执行指令

业务代码:

using System.Diagnostics;

private void InvokePostman()
{
    Process process = new Process();
    process.StartInfo.FileName = "cmd.exe";
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardInput = true;
    process.StartInfo.RedirectStandardOutput = true;
    process.StartInfo.RedirectStandardError = true;
    process.StartInfo.CreateNoWindow = true;
    process.StartInfo.WorkingDirectory = @"D:\Postman";
    process.Start();

    process.StandardInput.WriteLine("Postman.exe");
    process.StandardInput.AutoFlush = true;
    process.Close();
}

你可能感兴趣的:(.NET)