问题描述
我有一个 MSI 安装程序,我需要在其中从命令行添加或修改一个短文本属性.
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.
当我说属性"时,它可能是一个 MSI 属性、一个在安装时写入注册表的值,或者任何其他可以在安装的应用程序运行时将此简短的自定义文本导入到已安装应用程序中的机制.
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.
推荐答案
可用于在构建后更新(或添加)属性的示例 VBScript...
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
有关更多信息,请查看 Windows Installer SDK(Windows SDK)
For more information check out the Windows Installer SDK (part of the Windows SDK)
您可以从命令行使用大量示例脚本来执行各种 MSI 操作任务
There's a bunch of example scripts that you can use from the command line to do various MSI manipulation tasks
例如,WiRunSQL.vbs
允许您针对 MSI 执行任意 SQL.
For example WiRunSQL.vbs
lets you execute arbitrary SQL against an MSI.
这篇关于如何从命令行添加/更新 MSI 内的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!