Есть протенький код, который делает запрос в cmd
Подскажите, программа запрашивает трассировку в cmd, вопрос в том, как вывести результат этой команды в Console?
string command = "tracert 8.8.8.8";
System.Diagnostics.Process.Start("cmd.exe", "/C " + command);
Ответы (1 шт):
Автор решения: SukhovPro
→ Ссылка
Вот пример
using (Process process = new Process())
{
process.StartInfo.FileName = "ipconfig.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
// Synchronously read the standard output of the spawned process.
StreamReader reader = process.StandardOutput;
string output = reader.ReadToEnd();
// Write the redirected output to this application's window.
Console.WriteLine(output);
process.WaitForExit();
}