Created
September 29, 2015 17:37
-
-
Save ygunayer/d304ff0dc2d09857e86a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace hots | |
{ | |
class HotsHost | |
{ | |
static void Main(string[] args) | |
{ | |
var pi = new ProcessStartInfo(); | |
pi.FileName = @"C:\Program Files\Java\jdk1.8.0_51\bin\java.exe"; | |
pi.Arguments = @"-jar ""app\HotSLogs UploaderFX-jfx.jar"""; | |
pi.UseShellExecute = false; | |
pi.RedirectStandardOutput = true; | |
pi.RedirectStandardError = true; | |
pi.CreateNoWindow = true; | |
var p = new Process(); | |
p.StartInfo = pi; | |
p.ErrorDataReceived += StdOut_Received; | |
p.OutputDataReceived += StdErr_Received; | |
p.Start(); | |
p.BeginErrorReadLine(); | |
p.BeginOutputReadLine(); | |
p.WaitForExit(); | |
Console.WriteLine("Process has exited with code " + p.ExitCode); | |
} | |
static void StdErr_Received(object sender, DataReceivedEventArgs e) | |
{ | |
Console.WriteLine(e.Data); | |
} | |
static void StdOut_Received(object sender, DataReceivedEventArgs e) | |
{ | |
var prev = Console.ForegroundColor; | |
Console.ForegroundColor = ConsoleColor.Red; | |
Console.WriteLine(e.Data); | |
Console.ForegroundColor = prev; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment