mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 12:30:32 +00:00
32 lines
No EOL
874 B
C#
32 lines
No EOL
874 B
C#
using System.Diagnostics;
|
|
|
|
namespace Cosmos.Build.Common
|
|
{
|
|
public static class ProcessExtension
|
|
{
|
|
public static string LaunchApplication(string app, string args, bool waitForExit)
|
|
{
|
|
var start = new ProcessStartInfo();
|
|
start.FileName = app;
|
|
start.Arguments = args;
|
|
start.UseShellExecute = false;
|
|
start.CreateNoWindow = true;
|
|
start.RedirectStandardOutput = true;
|
|
start.RedirectStandardError = true;
|
|
|
|
var process = Process.Start(start);
|
|
|
|
if (waitForExit)
|
|
{
|
|
var output = process.StandardOutput.ReadToEnd();
|
|
|
|
process.WaitForExit();
|
|
|
|
var error = process.StandardError.ReadToEnd();
|
|
return output + error;
|
|
}
|
|
|
|
return string.Empty;
|
|
}
|
|
}
|
|
} |