mgorga
Posts: 45
Joined: Fri Jun 03, 2011 1:00 pm

Read properties and information of MSI database

Hello,
I wanted to read file version of a DLL included on the MSI installer and store it on a property. Then use it to update the Windows Registry. After I while I made it using a Custom Action and VBScript. I used this post like a reference:
http://www.advancedinstaller.com/forums ... f=1&t=3628

The solution is not controlling errors and It is not recommended using VBScript custom actions, it will be better with C# or C++:
http://www.advancedinstaller.com/user-g ... tml#vbs-ca

So It will be nice to have a feature to read the MSI Database. Then it will be possible to read all information about files, properties, features, etc. For example, using a Search it is possible to read file version of file existing on destination machine but it is quite difficult to do the same with file of your MSI!

That's the Custom Action:

Code: Select all

Function GetMSIFileVersion()
	Const msiOpenDatabaseModeReadOnly = 0
	Dim installer, database
	Dim myMSI
	Dim fileName, propName
	
	' Extracting FileName gived as parameter
	fileName = Session.Property("CustomActionData")
	
	' Property to store result
	propName = "MY_OUT_PROPERTY"
	
	' Get current MSI path
	myMSI = Session.Property("OriginalDatabase")
	
	' Open MSI Database
	SET installer = CreateObject("WindowsInstaller.Installer")
	SET database = installer.OpenDatabase(myMSI, msiOpenDatabaseModeReadOnly)
	
	' Query file version
	SET MSIView  = database.OpenView("select Version from File where File='"+fileName+"'")
	MSIView.Execute
	Set MSIrecords = MSIView.Fetch
	
	' Save file version to property
	Session.Property(propName) = MSIrecords.StringData(1)
End Function
Best regards,
Mario
Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Read properties and information of MSI database

Hi Mario,

We'll consider your suggestion for adding this feature, but for the moment there are not immediate plans. Thank you for your suggestion.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Feature Requests”