【问题标题】:Get msi product name, version from command line从命令行获取 msi 产品名称、版本
【发布时间】:2012-03-19 18:55:06
【问题描述】:

有没有办法从命令行显示产品名称和 msi 文件的版本?或者更好的是,这可以通过 python 完成吗?

【问题讨论】:

    标签: python windows-installer


    【解决方案1】:

    您可以使用以下方式获取产品版本:

    from msilib import *
    
    def GetMsiProperty(path ,property):
        db = OpenDatabase(path, MSIDBOPEN_READONLY)
        view = db.OpenView ("SELECT Value FROM Property WHERE Property='" + property + "'")
        view.Execute(None)
        result = view.Fetch()
        #print dir(result)
        return result.GetString(1)
    
    
    msiVersion = GetMsiProperty(r'C:\path\to.msi' ,"ProductVersion")
    

    您的 python 版本必须高于 2.5 才能使用上述功能。

    【讨论】:

      【解决方案2】:

      尝试SummaryInformation.GetProperty(PID_TITLE)SummaryInformation.GetProperty(PID_REVNUMBER) 以及the msilib docs page 中的所有其他字段名称

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-02-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-26
        相关资源
        最近更新 更多