Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSI doesn't run from within C#

I am trying to run an MSI file from C# using the Proces.Start method. The MSI file is fine, because I can run that normally, but when I try to run the MSI file within some C# code I receive the following error.

"This installation package could not be opened. Verify that the package exists, and that you can access it, or contact the application vendor to verify that this is a valid windows installer package"

Below is the code that I am using to run the MSI file...

Process p = Process.StartApplication.StartupPath  "/Packages/Name.msi");

p.WaitForExit();   

How can I fix this problem?


OK, I got it now. I just changed it to run the setup.exe file that is generated with the MSI file, instead of the running the MSI file...

like image 939
Cwisking Avatar asked Jan 05 '10 13:01

Cwisking


1 Answers

msi files cannot run on their own. If you double click on them, Windows will start

msiexec /i PathToYour.msi

Did you try to do that explicitly?

Example: (Courtesy @Webleeuw)

Process p = new Process();
p.StartInfo.FileName = "msiexec";
p.StartInfo.Arguments = "/i PathToYour.msi";
p.Start();
like image 162
Benjamin Podszun Avatar answered Sep 23 '22 05:09

Benjamin Podszun