使用管理员账户身份运行程序或进程:
startexePath:exe的路径
strPara:带参启动时,为exe的启动参数
System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity);
bool res = principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = startexePath;
startInfo.UseShellExecute = true;
// 使用管理员方式打开
startInfo.Verb = "runas";
startInfo.Arguments = strPara;
Process proc = Process.Start(startInfo);