当前位置:  开发笔记 > 数据库 > 正文

用于更改MSI中的动作序列记录的脚本

如何解决《用于更改MSI中的动作序列记录的脚本》经验,为你挑选了1个好方法。

要解决此处列出的问题,我必须在MSI中更改InstallExecuteSequence .RemoveExistingProducts记录.

我想将此作为构建过程的一部分,而不是与Orca混在一起



1> Ryan..:

修改MSI_SetProperty.js脚本给出

// MSI_SetActionSequence.js   
// Performs a post-build fixup of an msi to set the specified table/action/sequence

// Constant values from Windows Installer SDK
var msiOpenDatabaseModeTransact = 1;

var msiViewModifyInsert         = 1;
var msiViewModifyUpdate         = 2;
var msiViewModifyAssign         = 3;
var msiViewModifyReplace        = 4;
var msiViewModifyDelete         = 6;

if (WScript.Arguments.Length != 4)
{
    WScript.StdErr.WriteLine("Usage: " + WScript.ScriptName + " file table action sequence");
    WScript.Quit(1);
}

var filespec = WScript.Arguments(0);
var table = WScript.Arguments(1);
var action = WScript.Arguments(2);
var sequence = parseInt(WScript.Arguments(3));

var installer = WScript.CreateObject("WindowsInstaller.Installer");
var database = installer.OpenDatabase(filespec, msiOpenDatabaseModeTransact);

WScript.StdOut.WriteLine("Looking for action:" + action);

try
{   
    var sql = "SELECT Action, Sequence FROM " + table + " WHERE Action = '" + action + "'";
    var view = database.OpenView(sql);  

    view.Execute();     
    var record = view.Fetch();  

    if (record)
    {       
        while (record)
        {
            WScript.StdOut.Write("Found: " + record.StringData(0) + ", " + record.StringData(1) + ", " + record.StringData(2));
            if (record.IntegerData(2) != sequence)
            {
                WScript.StdOut.WriteLine(" - changing to " + sequence);
                record.IntegerData(2) = sequence;
                view.Modify(msiViewModifyUpdate,record);
            }
            else
                WScript.StdOut.WriteLine(" - OK");

            record = view.Fetch();
        }

        view.Close();
        database.Commit();
    }
    else
    {           
        view.Close();   
        throw("Warning - Could not find " + table + "." + action);
    }
}
catch(e)
{
    WScript.StdErr.WriteLine(e);
    WScript.Quit(1);
}


要调用此脚本来执行上面提到的操作序列的更改,您可以将以下内容放在批处理文件中,并从post构建事件中调用它,例如PostBuildEvent = $(ProjectDir)PostBuild.bat

cscript.exe MSI_SetActionSequence.js YOURINSTALLER.MSI InstallExecuteSequence RemoveExistingProducts 1525

推荐阅读
k78283381
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有