public static AsyncProcess Start(ProcessStartInfo startInfo, IDictionary environment) { startInfo.RedirectStandardError = true; startInfo.RedirectStandardOutput = true; startInfo.UseShellExecute = false; var redirecting = true; #if !CORECLR if (AdminPrivilege.IsElevated) { startInfo.Verb = ""; } else { if ("runas".EqualsIgnoreCase(startInfo.Verb)) { redirecting = false; startInfo.UseShellExecute = true; startInfo.RedirectStandardError = false; startInfo.RedirectStandardOutput = false; } } #endif if (environment != null) { foreach (var i in environment.Keys) { #if !CORECLR startInfo.EnvironmentVariables[(string)i] = (string)environment[i]; #else startInfo.Environment[(string)i] = (string)environment[i]; #endif } } var result = new AsyncProcess(new Process { StartInfo = startInfo }); result._process.EnableRaisingEvents = true; // set up std* access if (redirecting) { result._process.ErrorDataReceived += result.ErrorDataReceived; result._process.OutputDataReceived += result.OutputDataReceived; } result._process.Exited += result.ProcessExited; result._process.Start(); if (redirecting) { result._process.BeginErrorReadLine(); result._process.BeginOutputReadLine(); } return(result); }
public static AsyncProcess Start(ProcessStartInfo startInfo, IDictionary environment) { startInfo.RedirectStandardError = true; startInfo.RedirectStandardOutput = true; var redirecting = true; if (environment != null) { foreach (var i in environment.Keys) { startInfo.Environment[(string)i] = (string)environment[i]; } } var result = new AsyncProcess(new Process { StartInfo = startInfo }); result._process.EnableRaisingEvents = true; // set up std* access if (redirecting) { result._process.ErrorDataReceived += result.ErrorDataReceived; result._process.OutputDataReceived += result.OutputDataReceived; } result._process.Exited += result.ProcessExited; result._process.Start(); if (redirecting) { result._process.BeginErrorReadLine(); result._process.BeginOutputReadLine(); } return(result); }
public static AsyncProcess Start(ProcessStartInfo startInfo, IDictionary environment) { startInfo.RedirectStandardError = true; startInfo.RedirectStandardOutput = true; startInfo.UseShellExecute = false; var redirecting = true; #if !CORECLR if (AdminPrivilege.IsElevated) { startInfo.Verb = ""; } else { if ("runas".EqualsIgnoreCase(startInfo.Verb)) { redirecting = false; startInfo.UseShellExecute = true; startInfo.RedirectStandardError = false; startInfo.RedirectStandardOutput = false; } } #endif if (environment != null) { foreach (var i in environment.Keys) { #if !CORECLR startInfo.EnvironmentVariables[(string)i] = (string)environment[i]; #else startInfo.Environment[(string)i] = (string)environment[i]; #endif } } var result = new AsyncProcess(new Process { StartInfo = startInfo }); result._process.EnableRaisingEvents = true; // set up std* access if (redirecting) { result._process.ErrorDataReceived += result.ErrorDataReceived; result._process.OutputDataReceived += result.OutputDataReceived; } result._process.Exited += result.ProcessExited; result._process.Start(); if (redirecting) { result._process.BeginErrorReadLine(); result._process.BeginOutputReadLine(); } return result; }
public static AsyncProcess Start(ProcessStartInfo startInfo, IDictionary environment) { startInfo.RedirectStandardError = true; startInfo.RedirectStandardOutput = true; var redirecting = true; if (environment != null) { foreach (var i in environment.Keys) { startInfo.Environment[(string)i] = (string)environment[i]; } } var result = new AsyncProcess(new Process { StartInfo = startInfo }); result._process.EnableRaisingEvents = true; // set up std* access if (redirecting) { result._process.ErrorDataReceived += result.ErrorDataReceived; result._process.OutputDataReceived += result.OutputDataReceived; } result._process.Exited += result.ProcessExited; result._process.Start(); if (redirecting) { result._process.BeginErrorReadLine(); result._process.BeginOutputReadLine(); } return result; }