Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get msi product name, version from command line

Is there a way to display the product name and version of a msi file from the command line? Or better yet, can this be done via python?

like image 766
Luiz C. Avatar asked May 11 '26 00:05

Luiz C.


1 Answers

You can get the product version using:

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")

Your python version must be higher than 2.5 for the above function to work.

like image 138
Tjaart Avatar answered May 13 '26 14:05

Tjaart