This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user