This commit is contained in:
2020-05-19 21:29:52 +00:00
parent 2b61791f2a
commit 49fd0f2a7a

View File

@@ -47,7 +47,35 @@ namespace AyaNova.Util
private static string RunWindows(string cmd, string arguments)
{
/*
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.OutputDataReceived += (sender, args) => Console.WriteLine("received output: {0}", args.Data);
process.Start();
process.BeginOutputReadLine();
*/
// string result = string.Empty;
// using (var process = new Process())
// {
// process.StartInfo = new ProcessStartInfo
// {
// FileName = cmd,
// Arguments = arguments,
// RedirectStandardOutput = true,
// UseShellExecute = false,
// CreateNoWindow = true,
// };
// process.OutputDataReceived += (sender, args) => result += args.Data;
// process.Start();
// // string result = process.StandardOutput.ReadToEnd();
// // process.WaitForExit();
// return result;
// }
//this executes but doesnt return error
using (var process = new Process())
{
process.StartInfo = new ProcessStartInfo
@@ -55,12 +83,14 @@ namespace AyaNova.Util
FileName = cmd,
Arguments = arguments,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
};
process.Start();
string result = process.StandardOutput.ReadToEnd();
string result = $"{process.StandardOutput.ReadToEnd()}{process.StandardError.ReadToEnd()} ";
process.WaitForExit();
return result;
}