如何检测是否提供了/norestart 运行 msi

How to detect if /norestart is provided running msi

我正在使用 visual studio 安装项目构建 MSi。我想根据 /norstart 选项有不同的自定义操作 运行。我应该用什么条件来检测是否提供/norestart?

如果这不可能,我正在考虑设置一个 属性。这是我的理论。使用 Orca 设置 REBOOT=Force。如果我想抑制重启,运行 msi as

            foo.msi /quiet REBOOT=ReallySuppress

并从代码中读取 属性,例如

            String inputFile = @"C:\Users\Administrator\Desktop\foo.msi";
            // Get the type of the Windows Installer object
            Type installerType = Type.GetTypeFromProgID("WindowsInstaller.Installer");

            // Create the Windows Installer object
            WindowsInstaller.Installer installer = (WindowsInstaller.Installer) Activator.CreateInstance(installerType);

            // Open the MSI database in the input file
            var database = installer.OpenDatabase(inputFile, 0);

            // Open a view on the Property table for the version property
            var view = database.OpenView("SELECT * FROM `Property`");
            //View view = database.OpenView("SELECT * FROM Property");

            // Execute the view query
            view.Execute(null);

            // Get the record from the view
            Record record = view.Fetch();

            // Get the version from the data
            //string version = record.get_StringData(2);

            while (record != null)
            {
                logger.LogMessage(record.get_StringData(0) + '=' + record.get_StringData(1) + '=' + record.get_StringData(2) + '=' + record.get_StringData(3));
                record = view.Fetch();
            }

这不起作用,因为它总是读取 REBOOT=Force。

这个是我自己想出来的

CustomActionData 设置为 /reboot=[REBOOT].

然后读取值:

Context.Parameters["reboot"]

如果提供 /norestart 选项,重新启动的值将为 ReallySuppress