Can I look at an MSI and get the version?

  • Thread starter Thread starter M K
  • Start date Start date
M

M K

I would like to be able to have code view an MSI file and see what version
it is. This would save me from installing the app just to see if this CD has
the correct version on it. (My company is bad about labeling.) Also, I would
like my software's about box to show the version of the software without
having to change the text each time I update it.
 
Hi Mark,

Thanks for posting.

To get a version of the MSI package, we can use the COM component
"WindowsInstaller.Installer". The following is an example in VBScript:

=================================================
'Create Installer object.
Dim Installer
Set Installer = CreateObject("WindowsInstaller.Installer")
'Open the MSI database. You may change the path information as you like.
Dim Database
Set Database = Installer.OpenDatabase("e:\setup3.msi", 0)
'Create the SQL statement for query
Dim SQL
SQL = "SELECT * FROM Property WHERE Property = 'ProductVersion'"
'Open the view and execute the SQL statement
Dim View
Set View = DataBase.OpenView(SQL)
View.Execute
'Fetch the record for the "ProductVersion" property
Dim Record
Set Record = View.Fetch
'Show the result.
MsgBox Record.StringData(2)
=================================================

For more information on automation interface on Windows Installer, you may
visit the link below:
http://msdn.microsoft.com/library/?url=/library/en-us/msi/setup/automation_i
nterface.asp?frame=true

As far as how to show the application version automatically, in fact the
application version is different from the Windows Installer package
version. Could you let me know what programming language you are using?

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top