I am reading a MSI file using python msilib library. My aim is to extract [Binary Data] from Binary table and dump into a file. (Using ORCA tool, we can extract the binary data by double clicking [Binary Data] cell and write to a file)
I could not find any msilib method to get binary data. It have method to get string data using Record.GetString(field). But as expected this is not working for [Binary Data] and give error.
Here is the code snippet
import msilib
# msi file path which is to be read
msiFilePath = "C:/msi/test.msi"
dbObj = msilib.OpenDatabase(msiFilePath, msilib.MSIDBOPEN_READONLY)
sqlQuery = "select * from Binary"
view = dbObj.OpenView(sqlQuery)
view.Execute(None)
cur_record = viewObj.Fetch()
# In Binary table; Column no 1 have string data and Column # 2 have [Binary Data]
cur_record.GetString(2)
And on execution :-
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
cur_record.GetString(2)
_msi.MSIError: unknown error 70c
Is there any way to do that ?