C# 以管理员权限启动应用

ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.UseShellExecute = false;
startInfo.WorkingDirectory = Environment.CurrentDirectory;
startInfo.FileName = "InstallUtil.exe";
startInfo.Arguments = "NTPClientService.exe";
//设置启动动作,确保以管理员身份运行
startInfo.Verb = "runas";
Process process = System.Diagnostics.Process.Start(startInfo);
process.WaitForExit(30 * 1000);

 

posted @ 2024-05-23 01:21  microsoft-zhcn  阅读(39)  评论(0编辑  收藏  举报