How do I add/update a property inside an MSI from the command-line?

Example VBScript that you could use to update (or add) a property post-build...

    Option Explicit

    Const MSI_FILE = "myfile.msi"


    Dim installer, database, view

    Set installer = CreateObject("WindowsInstaller.Installer")
    Set database = installer.OpenDatabase (MSI_FILE, 1)

    ' Update
    Set view = database.OpenView ("UPDATE Property SET Value = '" & myproperty & "' WHERE Property = 'MYPROPERTY'")

    ' .. or Add (Insert)
    Set view = database.OpenView ("INSERT INTO Property (Property, Value) VALUES ('MYPROPERTY', '" & myproperty & "')")
    view.Execute
    database.Commit

    Set database = Nothing
    Set installer = Nothing
    Set view = Nothing

For more information check out the Windows Installer SDK (part of the Windows SDK)

There's a bunch of example scripts that you can use from the command line to do various MSI manipulation tasks

For example WiRunSQL.vbs lets you execute arbitrary SQL against an MSI.


This is to add to @saschabeaumont 's answer in '09. Currently using dotNet 4.0

Option Explicit

Const MSI_FILE = "myFilePath.msi"
Const PROPERTY_STRING_Value = "FooBar"

Dim installer, database, view

Set installer = CreateObject("WindowsInstaller.Installer")
Set database = installer.OpenDatabase (MSI_FILE, 1)

' Update
Set view = database.OpenView ("UPDATE Property SET Value = '" & PROPERTY_STRING_Value & "' WHERE Property = 'MYPROPERTY'")

' .. or Add (Insert)
Set view = database.OpenView ("INSERT INTO Property (Property, Value) VALUES ('MYPROPERTY', '" & PROPERTY_STRING_Value & "')")

view.Execute()
database.Commit()

Set database = Nothing
Set installer = Nothing
Set view = Nothing

c:\> msiexec /i yourmsi.msi THEPROPERTYNAME=valueofproperty

For more information type msiexec at the commandline.

EDIT: or change the .msi file itself by using sql statements and updating the property in the properties table: http://msdn.microsoft.com/en-us/library/aa372021(VS.85).aspx http://msdn.microsoft.com/en-us/library/aa368568(VS.85).aspx