I have an msi installer that I need to install it silently from the 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
when I run it I just get the cmd screen in admin mode but the command does not executing
Run MSI as administrator from Command Prompt To do so, type CMD in Start menu or Start screen search box, and then simultaneously press Ctrl+Shift+Enter keys.
If a program requires Administrator privileges to perform certain functions, you need to run the program as Administrator. To run a program as Administrator in Windows 10, right-click the icon in your Start menu and select Run as administrator.
as V2Solutions - MS Team mentioned , the solution is to change the following
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With