当前位置:  开发笔记 > 后端 > 正文

将MSIUSEREALADMINDETECTION添加到MSI的脚本

如何解决《将MSIUSEREALADMINDETECTION添加到MSI的脚本》经验,为你挑选了1个好方法。

任何人都有这个方便脚本的精神脚本(JScript,VBScript或类似),但添加了MSIUSEREALADMINDETECTION属性

我知道我可以手动使用Orca或使用它的变换功能,但宁可不去那里.



1> Ryan..:

一些参考

Windows Installer SDK - 执行SQL语句

wirunsql.vbs

修改问题中引用的CustomAction_NoImpersonate.js会生成此脚本,该脚本可以在Properties表中添加/设置任何值.

使用"cscript.exe MSI_SetProperty.js your.msi属性值"调用

// MSI_SetProperty.js   
// Performs a post-build fixup of an msi to set the specified property (and add it if it doesn't already exist)

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

if (WScript.Arguments.Length != 3)
{
    WScript.StdErr.WriteLine("Usage: " + WScript.ScriptName + "file property value");
    WScript.Quit(1);
}

var filespec = WScript.Arguments(0);
var property = WScript.Arguments(1);
var value = parseInt(WScript.Arguments(2));
var installer = WScript.CreateObject("WindowsInstaller.Installer");
var database = installer.OpenDatabase(filespec, msiOpenDatabaseModeTransact);

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

try
{   
    var sql = "SELECT Property, Value FROM Property WHERE Property = '" + property + "'";   
    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) != value)
            {
                WScript.StdOut.WriteLine(" - changing to " + value);
                record.IntegerData(2) = value;
                view.Modify(msiViewModifyUpdate,record);
            }
            else
                WScript.StdOut.WriteLine(" - OK");

            record = view.Fetch();
        }
    }
    else
    {           
        WScript.StdOut.WriteLine("Not found, so adding");
        // There may be a better way to do this?
        sql = "INSERT INTO Property (Property,Value) VALUES ('" + property + "','" + value + "')";
        view = database.OpenView(sql);
        view.Execute();     
    }
    view.Close();
    database.Commit();
}
catch(e)
{
    WScript.StdErr.WriteLine(e);
    WScript.Quit(1);
}

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