asuppa
asuppa

Reputation: 571

msi will not execute with processStart

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

Answers (2)

Philm
Philm

Reputation: 3674

You have to tweak your command line on several issues to be optimal, and mainly to be supportable.

  1. Don't use the ProcessWindowStyle.Hidden Option here. You don't need to. As long as you are testing , use the "/qb" parameter. For release, if you want no dialog, just use "/qn"

I think using not /qn but forbidding to open the window can be the source of the problem.

  1. 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.

  2. Use logging.

  3. 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

OKEEngine
OKEEngine

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

Related Questions