Skip to content

Instantly share code, notes, and snippets.

@adrianstevens
Created January 19, 2015 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adrianstevens/13698d6c7210b3855528 to your computer and use it in GitHub Desktop.
Save adrianstevens/13698d6c7210b3855528 to your computer and use it in GitHub Desktop.
WPF execute command line
using System;
using System.Diagnostics;
using System.IO;
class Program
{
static void Main()
{
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = @"C:\someapp.exe"; // full path
start.UseShellExecute = false;
start.RedirectStandardOutput = true;
using (Process process = Process.Start(start))
{
// Read in all the text from the process using StreamReader
using (StreamReader reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
Console.Write(result);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment