Ate*_*eeq 6 c# cmd admin process
我有一个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);
Run Code Online (Sandbox Code Playgroud)
注意到cmd命令工作正常,如果我从cmd手动运行它作为管理员
当我运行它时,我只是在管理模式下获取cmd屏幕,但命令没有执行
作为V2Solutions - MS团队提到,解决方案是改变以下内容
process.StartInfo.FileName = "msiexe.exe"
Run Code Online (Sandbox Code Playgroud)
而代码将是
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);
Run Code Online (Sandbox Code Playgroud)
这对我有用:)
这也将对您有所帮助:
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();
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6244 次 |
最近记录: |