Specify quiet and norestart on msi installation ex

2019-09-19 14:36发布

问题:

all!

I am using the dynamic library "Microsoft.Deployment.WindowsInstaller.dll" (from Windows Installer XML, that is, http://wixtoolset.org/), in my C# project, to install a MSI package programatically:

using System;
using Microsoft.Deployment.WindowsInstaller;

private static void InstallWIXML(string msiPackage)
{
    Installer.InstallProduct(msiPackage, "REBOOT=R");
}

. But I don't know how to make this automatic, not restartable, quiet, installation. This InstallWIXML method does a manual (it is case dependent!), not restartable, not quiet (it is case dependent!), installation.

Thanks for some help!

回答1:

I used the following code, like in my comment of the Christopher Painter's answer:

using System;
using Microsoft.Deployment.WindowsInstaller;

private static void InstallWIXML(string msiPackage)
{
    Installer.SetInternalUI(InstallUIOptions.Silent);
    Installer.InstallProduct(msiPackage, "REBOOT=R");
}

. It works for my question.

Thanks for the Christopher Painter's answer and comments, too!



回答2:

Change REBOOT=R to REBOOT=R /QN. Also realize that in a silent installation the installer can't ask for UAC elevation. If the calling process isn't elevated and the MSI needs elevation it will fail. This will likely be bubbled back up to the client as an exception.