在 msi 安装程序中安装 MSOLEDBSQL 驱动程序

发布于 2025-01-11 11:35:54 字数 1340 浏览 0 评论 0原文

我的产品有一个 MSI 安装程序,需要 MSOLEDBSQL 驱动程序才能运行。我试图将驱动程序安装作为主安装程序的一部分,而不是作为先决条件(这是迄今为止的处理方式)。

以下是我编写的用于在主安装程序的代码中安装驱动程序的代码:

public static void InstallSQLDriver()
        {

            Logger.LogInfo("Installing the MSOLEDBSQL Driver");
            ProcessStartInfo startInfo = new ProcessStartInfo("msiexec.exe", $"/i msoledbsql.msi /quiet IAcceptMSOLEDBSQLLicenseTerms=YES  /qn ACCEPTEULA=1 /norestart ALLUSERS=1");
            startInfo.Verb = "runas";
            startInfo.UseShellExecute = true;
            try
            {
                Process proc = Process.Start(startInfo);
                proc.WaitForExit();
                if (proc.ExitCode == 0)
                {
                    Logger.LogInfo("MSOLEDBSQL Driver Installation successful");
                }
                else
                {
                    Logger.LogInfo("MSOLEDBSQL Driver Installation failed. Process ended with code : " + proc.ExitCode);
                }
            }
            catch (Exception ex)
            {

                Logger.LogInfo("MSOLEDBSQL Driver Installation failed with error : " + ex.Message);
            }
        }

但是,运行此代码会在日志中出现错误,退出代码为 1618,并显示:另一个安装已在进行中。在继续此安装之前完成该安装。

我知道我们不能同时运行 2 个 MSI,但是我们可以进行任何更改来完成我想要做的事情吗?有谁知道如何在启动主应用程序的安装程序之前避免使用先决条件安装?

I have an MSI installer for my product which needs the MSOLEDBSQL driver to run. I am trying to include the driver installation as part of the main installer and not as a pre-requisite (which is how it was being handled till now).

Following is the code I have written to install the driver within my main installer's code :

public static void InstallSQLDriver()
        {

            Logger.LogInfo("Installing the MSOLEDBSQL Driver");
            ProcessStartInfo startInfo = new ProcessStartInfo("msiexec.exe", 
quot;/i msoledbsql.msi /quiet IAcceptMSOLEDBSQLLicenseTerms=YES  /qn ACCEPTEULA=1 /norestart ALLUSERS=1");
            startInfo.Verb = "runas";
            startInfo.UseShellExecute = true;
            try
            {
                Process proc = Process.Start(startInfo);
                proc.WaitForExit();
                if (proc.ExitCode == 0)
                {
                    Logger.LogInfo("MSOLEDBSQL Driver Installation successful");
                }
                else
                {
                    Logger.LogInfo("MSOLEDBSQL Driver Installation failed. Process ended with code : " + proc.ExitCode);
                }
            }
            catch (Exception ex)
            {

                Logger.LogInfo("MSOLEDBSQL Driver Installation failed with error : " + ex.Message);
            }
        }

However, running this gets me an error with exit code 1618 in my log saying : Another installation is already in progress. Complete that installation before proceeding with this install.

I know that we can't run 2 MSIs concurrently, but are there any changes we can make to do what I am trying to do. Does anyone know how to avoid using a pre-requisite installation before I can start my main application's installer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秉烛思 2025-01-18 11:35:54

我认为您可以在 InstallExecuteSequence 中的 InstallValidateInstallInitialize 之间或在 InstallFinalize 之后执行此操作(添加自定义操作)(也在InstallExecuteSequence中)

I think you can do it (add a Custom Action) between InstallValidate and InstallInitialize in InstallExecuteSequence or after InstallFinalize (also in InstallExecuteSequence)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文