Reputation: 571
Running install programs from the c# code I can successfuly install .exe files and uninstall both exe and msi files... however whenever launching an msi for installation it just sits there and never does anything....
start = new ProcessStartInfo("msiexec.exe", "/i \"" + tempDir + "/" + s.executable + "\"");
start.WindowStyle = ProcessWindowStyle.Hidden;
start.CreateNoWindow = true;
Process.Start(start).WaitForExit();
can anyone spot my mistake. I understand the wait for exit will wait indefinatly and that is fine as there will be 10-12 installs going synchronously but It never actually installs.....
Upvotes: 1
Views: 883
Reputation: 3674
You have to tweak your command line on several issues to be optimal, and mainly to be supportable.
I think using not /qn but forbidding to open the window can be the source of the problem.
Assure that your program is already started with admin rights, otherwise you will have a more complicated UAC situation under Vista, Win7 ff. and you really need the dialog to allow the UAC dialog. If your program is already started with admin rights, you can use "/qn" and have other simplifications of scenarios which I would recommend for beginners to MSI.
Use logging.
Using backslashes in Windows is safer although slashes may work sometimes too. => I would recommend a resulting command line like this.
string msicmd; msicmd="msiexec.exe /i \"" + tempDir + @"\" + msifile + @"\" /qb /L*v \"tempDir\mylogfile\"");
// Show a trace of this command line to debug it in case of errors :-)
...
Upvotes: 0
Reputation: 908
I had a look of msiexec.exe document. It seems that it only works with *.msi file. I tried your code with msi file, it works well.
There is a minor problem with your code. The directory path should be the other way around.
start = new ProcessStartInfo("msiexec.exe", "/i \"" + tempDir + "\\" + s.executable + "\"")
Upvotes: 1