Luiz C.
Luiz C.

Reputation: 776

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?

Upvotes: 3

Views: 3359

Answers (3)

André Matzke
André Matzke

Reputation: 1

unfortunately the msilib is deprecated with python 3.13.

https://peps.python.org/pep-0594/#msilib

Upvotes: 0

Tjaart
Tjaart

Reputation: 4129

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.

Upvotes: 5

vpit3833
vpit3833

Reputation: 7961

Try SummaryInformation.GetProperty(PID_TITLE) and SummaryInformation.GetProperty(PID_REVNUMBER) and all the other field names at the msilib docs page

Upvotes: 2

Related Questions