C# – MSI doesn’t run from within C#

cwindows-installer

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…

Best Answer

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();
Related Topic