提问人:pryape 提问时间:10/24/2023 更新时间:10/24/2023 访问量:41
我想使用 CMD 运行 Visual DisableOutOfProcBuild.exe 安装程序,但 CMD 在不执行命令的情况下运行
I want to run the Visual DisableOutOfProcBuild.exe installer using CMD, but the CMD runs without executing the command
问:
我尝试以管理员身份运行我的软件并检查这是否是权限问题,但无济于事。
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();
答:
0赞
Giuseppe Previti
10/24/2023
#1
在命令字符串中,首先放置 /C
/C cd \C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\VSI\DisableOutOfProcBuild\ && DisableOutOfProcBuild.exe
评论
0赞
pryape
10/24/2023
它运行成功,谢谢。
评论
cmd.exe
Process
CreateProcess
cmd.exe
CreateProcess
C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\VSI\DisableOutOfProcBuild\DisableOutOfProcBuild.exe
Process
cmd.exe
process1.StartInfo.WorkingDirectory = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\CommonExtensions\\Microsoft\\VSI\\DisableOutOfProcBuild";
如果确实需要当前目录是 的目录,则可用于通过函数参数将此目录路径传递给 。我怀疑这是否是必要的,因为 Microsoft 可执行文件通常独立于当前目录所在的目录,使用完全限定的文件名来启动可执行文件。lpCurrentDirectory
CreateProcess
DisableOutOfProcBuild.exe