[C#] 调用有管理员权限的CMD

ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.FileName = "cmd.exe";
                startInfo.Arguments = "/c C:\\Windows\\System32\\cmd.exe";
                startInfo.RedirectStandardInput = true;
                startInfo.RedirectStandardOutput = true;
                startInfo.RedirectStandardError = true;
                startInfo.UseShellExecute =false ;
                startInfo.Verb = "RunAs";
                Process process = new Process();
                process.StartInfo = startInfo;
                process.Start();
                process.StandardInput.WriteLine("bcdedit");
                process.StandardInput.WriteLine("exit");
                string strRst = process.StandardOutput.ReadToEnd();
                Bootinitext.AppendText("\n"+strRst );
                process.WaitForExit();
原文地址:https://www.cnblogs.com/SpeakHero/p/2439933.html