如何从命令行在MSI中添加/更新属性? [英] How do I add/update a property inside an MSI from the command-line?

查看:255
本文介绍了如何从命令行在MSI中添加/更新属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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


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

有关详细信息,请参阅Windows Installer SDK( Windows SDK ),有一堆示例脚本可以使用命令行来执行各种MSI操作任务,例如 WiRunSQL.vbs 允许您对MSI执行任意SQL。

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.

这篇关于如何从命令行在MSI中添加/更新属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆