从命令行获取 MSI 产品名称和版本
有没有办法通过命令行显示一个msi文件的产品名称和版本号?或者更好的是,这能通过Python来实现吗?
2 个回答
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,这样上面的功能才能正常使用。
2
试试用 SummaryInformation.GetProperty(PID_TITLE)
和 SummaryInformation.GetProperty(PID_REVNUMBER)
这些方法,还有其他在 msilib 文档页面 上的字段名称。