private static void Elevate(ConnectArgs arguments) { string key = @"HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameter"; if (arguments.show) { ProcessStartInfo info = new ProcessStartInfo() { Arguments = "/c reg query " + key, FileName = "cmd.exe" }; info.RedirectStandardOutput = true; info.UseShellExecute = false; var p = Process.Start(info); p.WaitForExit(); Console.WriteLine(p.StandardOutput.ReadToEnd()); if (p.ExitCode != 0) { Console.WriteLine("Default port configuration is present on the system."); } } else if (arguments.fix) { ProcessStartInfo info = new ProcessStartInfo() { Arguments = "/c reg add " + key, FileName = "cmd.exe" }; info.RedirectStandardOutput = true; info.UseShellExecute = false; var p = Process.Start(info); p.WaitForExit(); Console.WriteLine(p.StandardOutput.ReadToEnd()); if (p.ExitCode != 0) { Console.WriteLine("Default port configuration is present on the system."); } } }