Ido A
Ido A

Reputation: 87

Getting MSI properties python

I have an MSI file that I'm trying to extract some of the parameters specified in the Details tab on the file properties.

I found the msilib where SummaryInformation.GetProperty(field) looks like the way to go, but I don't understand how to use it. how do I 'connect' it to that existing MSI file and not one that is being created?

Upvotes: 0

Views: 1971

Answers (1)

Ohad
Ohad

Reputation: 176

The msi file contains both cab files and information in a database format. See this link for more info about its structre and how to view it: MSI structure answer.

I never used the python msilib but by reading the documentation my guess is this:

  1. to get the db object, use something like: dbobject = msilib.OpenDatabase(path, msilib.MSIDBOPEN_READONLY)

  2. if you want something in the summary info then you can do something like: info = dbobject.GetSummaryInformation(1) prop = info.GetProperty(field)

  3. if the information you need is in one of the db tables then you should do a sql query against it: view = dbobject.OpenView(sql) rec = view.Execute(params) str_val = rec.GetString(field)

Upvotes: 5

Related Questions