Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Process process = new Process();
process.StartInfo.FileName = "msiexec.exe";

process.StartInfo.Arguments = string.Format=(@"/i E:\My Steup Files\Installer.msi {0}", config.parameter);

process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = false;
process.Start();
process.WaitForExit();


when I using the above code to start a process, if the paramters(get from a configuration file) is not correct, the windows installer help dialog will pop up.
How could I config the startInfo to avoid this dialog and just let the code fail when the argument is not correct?
Posted
Updated 4-Dec-11 20:48pm
v4

To install MSI files silently use the /quiet command line.

http://msdn.microsoft.com/en-us/library/windows/desktop/aa372024%28v=vs.85%29.aspx[^]
 
Share this answer
 
Comments
sesha Fan 5-Dec-11 2:50am    
I mean when the argument is not correct, how to avoid the windows installer help dialog? Or how can I know the argument is not correct according the return value?Because the argument is configed by other people.
solved code:
C#
Process process = new Process();
process.StartInfo.FileName = "msiexec.exe";
 
process.StartInfo.Arguments = string.Format=(@"/i E:\My Steup Files\Installer.msi {0}", config.parameter);
 
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = false;
process.Start();
process.WaitForExit(100*1000);

if((process.HasExit && process.ExitCode != 0) || !process.HasExit)
{
   return error; // Code fails here, you can throw expection.
}

if(process != null && !process.HasExit)
{
    process.CloseMainWindow();
    process.Close();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900