如何以编程方式读取 MSI 文件内的属性?
有没有办法读取 MSI 文件中的属性?
例如,给定一个名为 Testpackage.msi 的 MSI 文件,我需要找到
productName
PackageCode
version
此文件,我将在 WMI 卸载中使用它
string objPath = string.Format("Win32_Product.IdentifyingNumber='{0}', Name='{1}', Version='{2}'", "{AC9C1263-2BA8-4863-BE18-01232375CE42}", "testproduct", "10.0.0.0");
使用 Orca 是一个很好的选择,如果这可以通过编程实现。 然后我可以用它来生成自动发行说明。 也在卸载程序中。
Is there a way to read the properties inside an MSI file?
For example, given a MSI file named Testpackage.msi, I need to find
productName
PackageCode
version
This I am going to use it with WMI uninstall
string objPath = string.Format("Win32_Product.IdentifyingNumber='{0}', Name='{1}', Version='{2}'", "{AC9C1263-2BA8-4863-BE18-01232375CE42}", "testproduct", "10.0.0.0");
Using Orca is a great option, if this can be achieved programmatically. Then I can use this to generate automatic release notes. And in un-installing program too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用基于 COM 的 API 来处理 MSI< /a>,然后做类似的事情
You can use the COM-based API for working with MSI, and do something like
我只想提一下,现在事情变得更加容易了。 Windows Installer 对象模型有一个完整的 .NET 包装器,因此您可以避免任何 COM 互操作的笨拙。
该包装器称为“部署工具基础”(DTF),以下是基本描述:“部署工具基础是一组丰富的 .NET 类库和相关资源,它们将 Windows它旨在大大简化与部署相关的开发任务,同时仍然公开底层技术的完整功能。”。
这是一个精简的实践示例:
主要 DTF 文件(后两个是最常用的文件):
只需创建一个 C# 项目,引用这些文件,并使用您想要和需要的任何控件编写您自己的部署应用程序。 我目前尚未设置 DTF 工具,但请参阅此示例 C# 程序如何工作的一般概念。
I just want to mention that things have gotten even easier now. There is a full .NET wrapper for the Windows Installer object model, so you can avoid any COM interop clunkiness.
The wrapper is called "Deployment Tools Foundation" (DTF) and here is the basic description: "Deployment Tools Foundation is a rich set of .NET class libraries and related resources that together bring the Windows deployment platform technologies into the .NET world. It is designed to greatly simplify deployment-related development tasks while still exposing the complete functionality of the underlying technology".
Here is a stripped-down, hands-on sample:
Primary DTF files (the latter two are the most used ones):
Just create a C# project, reference these files, and code your own deployment application with whatever control you desire and need. I am not set up with the tools for DTF at the moment, but see this sample for a general idea of how a C# program would work.
您可以使用Microsoft 的 Orca.exe。 Orca 将允许您打开 MSI 并编辑/查看其中的所有表。 您必须下载整个 Windows SDK为了得到它,但幸运的是这是免费的。
一种替代方案(由于 SDK 的下载大小可能会更快)是使用 WiX 项目。 Dark 是一个 MSI 反编译器,它将所有内容导出到 XML 文件和资源集合中。 它输出的 XML 将包含您正在查找的信息。
You can use Microsoft's Orca.exe. Orca will allow you to open the MSI and edit/view all the tables in it. You will have to download the entire Windows SDK in order to get it, but thankfully that is free.
One alternative (which might be faster due to the download size of the SDK) is to use dark.exe from the WiX project. Dark is a MSI decompiler, which will export everything into an XML file and collection of resources. The XML it outputs will have the information you are looking for.
这是 VBScript 中的一个类似示例,我将其用作创建引导程序可执行文件的构建过程的一部分...
Here's a similar example in VBScript which I use as part of my build process in creating bootstrapper executables...
我在 lessmsi 中找到了一个轻量级非编程解决方案。 它显然使用 wix 并将整个 .msi 分解到指定的文件夹中。 (它也有一个 UI,但在 Win7 上对我来说效果不太好)。
I found a lightweight non-programmatic solution in lessmsi. It apparently uses wix and just explodes the whole .msi into a specified folder. (It also has a UI but it didn't render great for me on Win7).