从命令行获取msi产品名称,版本

时间:2010-07-01 12:54:11

标签: python windows-installer

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

2 个答案:

答案 0 :(得分:5)

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

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才能使上述功能正常工作。

答案 1 :(得分:2)

the msilib docs page

尝试SummaryInformation.GetProperty(PID_TITLE)SummaryInformation.GetProperty(PID_REVNUMBER)以及所有其他字段名称