[英]How to run msi installer in cmd as admin using C#
I have an msi installer that I need to install it silently from the C# 我有一个msi安装程序,我需要从C#静默安装它
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.WorkingDirectory = @"C:\temp\";
process.StartInfo.Arguments = "msiexec /quiet /i Setup.msi ADDLOCAL=test";
process.StartInfo.Verb = "runas";
process.Start();
process.WaitForExit(60000);
noting that the cmd command is working fine if I manually run it from the cmd as admin 注意到cmd命令工作正常,如果我从cmd手动运行它作为管理员
when I run it I just get the cmd screen in admin mode but the command does not executing 当我运行它时,我只是在管理模式下获取cmd屏幕,但命令没有执行
as V2Solutions - MS Team mentioned , the solution is to change the following 作为V2Solutions - MS团队提到,解决方案是改变以下内容
process.StartInfo.FileName = "msiexe.exe"
and the code will be 而代码将是
Process process = new Process();
process.StartInfo.FileName = "msiexec";
process.StartInfo.WorkingDirectory = @"C:\temp\";
process.StartInfo.Arguments = " /quiet /i Setup.msi ADDLOCAL=test";
process.StartInfo.Verb = "runas";
process.Start();
process.WaitForExit(60000);
this works for me :) 这对我有用:)
This is also going to help you: 这也可以帮助你:
Process process = new Process();
process.StartInfo.FileName = "msiexec.exe";
process.StartInfo.Arguments = string.Format("/qn /i \"{0}\" ALLUSERS=1", @"somepath\msiname.msi");
process.Start();
process.WaitForExit();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.