Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have an MSI installer in which I need to add or modify a short text property from the command-line.

This has to be done after the installer is built; I cannot modify the process that produces the installer in the first place. It also has to be executed headless from a script.

When I say "property," it could be an MSI property, a value that gets written to the registery at install-time, or any other mechanism that can get this short custom text into the installed application when it runs.

like image 551
Jason Cohen Avatar asked Oct 22 '09 18:10

Jason Cohen


1 Answers

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
like image 112
asarenski Avatar answered Oct 19 '22 09:10

asarenski