我尝试以管理员身份运行我的软件并检查是否是权限问题,但无济于事。
string command = "cd \"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\CommonExtensions\\Microsoft\\VSI\\DisableOutOfProcBuild\" && DisableOutOfProcBuild.exe";
Process process1 = new Process();
process1.StartInfo.FileName = "C:\\Windows\\System32\\cmd.exe";
process1.StartInfo.Arguments = command;
process1.StartInfo.UseShellExecute = false;
process1.StartInfo.RedirectStandardOutput = true;
process1.StartInfo.RedirectStandardError = true; // Activer la redirection de la sortie d'erreur
process1.StartInfo.CreateNoWindow = false;
process1.StartInfo.Verb = "runas";
process1.Start();
process1.BeginOutputReadLine();
process1.BeginErrorReadLine();
process1.WaitForExit();
在命令字符串中先放 /C
/C cd \C:\Program Files\Microsoft Visual Studio�2\Professional\Common7\IDE\CommonExtensions\Microsoft\VSI\DisableOutOfProcBuild\ && DisableOutOfProcBuild.exe