| 39 | } |
| 40 | |
| 41 | public static void Invoke(string args) |
| 42 | { |
| 43 | using (var process = new Process |
| 44 | { |
| 45 | StartInfo = new ProcessStartInfo |
| 46 | { |
| 47 | FileName = "cmd.exe", |
| 48 | Arguments = $"/C {args}", |
| 49 | RedirectStandardOutput = true, |
| 50 | RedirectStandardError = true, |
| 51 | UseShellExecute = false, |
| 52 | CreateNoWindow = true |
| 53 | } |
| 54 | }) |
| 55 | { |
| 56 | process.Start(); |
| 57 | process.WaitForExit(); |
| 58 | var error = process.StandardError.ReadToEnd(); |
| 59 | |
| 60 | if (process.ExitCode != 0 || !string.IsNullOrEmpty(error)) |
| 61 | { |
| 62 | throw new InvalidOperationException(error); |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |