Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
483 views
in Technique[技术] by (71.8m points)

windows - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...