Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
Process process = new Process();
process.StartInfo.FileName = @"msiexec.exe"; 

process.StartInfo.Arguments = string.Format(@"/i E:\My Steup Files\Installer.msi");

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 execute above code, the Windows Installer help window comes out.
I think the parameter is correct, I don't know why it cannot execute.
Does anyone know the reason? Thanks for your help!
Posted
Updated 1-Dec-11 18:38pm
v3
Comments
[no name] 1-Dec-11 22:04pm    
EDIT: added "pre" tag
Sergey Alexandrovich Kryukov 1-Dec-11 23:57pm    
Why? why?!
--SA

Hi seshaliang,

you can try it
Process.Start("msiexec.exe");
 
Share this answer
 
I am sorry. I didn't find the error point so my question isn't very clear.
The real cause is the path of msi file contains space, then window installer help dailog pops up.
I think it analysises params by spaces.
example: msiexec.exe /i E:\My Steup Files\Installer.msi /qn
Add quotes for the path is OK. Now the cmdLine is: msiexec.exe /i "E:\My Steup Files\Installer.msi" /qn
 
Share this answer
 
v3
Comments
sesha Fan 2-Dec-11 0:39am    
If anyone meet this problem, it may help you.
//Please try this code:
Process process = new Process();
process .StartInfo.WorkingDirectory = @"E:\Source"; //sets the working directory in which the exe file resides.
process.StartInfo.FileName = "msiexec.exe";

process.StartInfo.Arguments = string.Format(@"/i E:\My Steup Files\Installer.msi"); //Pass the number of arguments.

process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = false;
process.Start();
process.WaitForExit();
 
Share this answer
 
v2
Comments
[no name] 23-Sep-14 10:11am    
Why are you answering a 3 year old question that has already been answered?

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