C#调用CMD命令

  Process process = new Process
            {
                StartInfo = { FileName = "cmd.exe", UseShellExecute = false, RedirectStandardInput = true,                                                                                RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true }
            };
            process.Start();
            process.StandardInput.WriteLine("mstsc /v:101.112.119.156 /f");
            process.Close();
如果想使用其他命令只需要替换WriteLine中的字符串即可。

你可能感兴趣的:(C#,cmd)