refactor implementation

This commit is contained in:
Gregor Biswanger
2017-10-05 21:28:47 +02:00
parent 27e5f87ccd
commit d224e7b1ad
5 changed files with 71 additions and 125 deletions

View File

@@ -0,0 +1,33 @@
using System;
using System.Diagnostics;
namespace ElectronNET.CLI
{
public class ProcessHelper
{
public static void CmdExecute(string command, string workingDirectoryPath, bool output = true)
{
using (Process cmd = new Process())
{
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.StartInfo.WorkingDirectory = workingDirectoryPath;
cmd.Start();
cmd.StandardInput.WriteLine(command);
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.WaitForExit();
if (output)
{
Console.WriteLine(cmd.StandardOutput.ReadToEnd());
}
}
}
}
}