简体   繁体   English

如何在命令行上将MSM文件转换为MSI文件? 使用Windows Installer SDK或COM进行此操作

[英]How to convert an MSM file into an MSI file on the command line? Doing this with the Windows Installer SDK, or COM

I have a MSM file from a third party tool. 我有第三方工具提供的MSM文件。 We customize the MSM with a small script and this tool is integrated into our installer and works fine. 我们使用一个小的脚本来自定义MSM,并且此工具已集成到我们的安装程序中,并且运行良好。 All modification is done with VBscript using COM and "WindowsInstaller.Installer" 所有修改都是通过VBscript使用COM和“ WindowsInstaller.Installer”完成的

But sometimes our support needs just this tool as standalone installer package. 但是有时我们的支持人员只需要将此工具作为独立的安装程序包即可。

Is there a simple way to convert a MSM file into and full installer MSI package on the command line? 有没有一种简单的方法可以在命令行上将MSM文件转换为完整的安装程序MSI软件包?

Using VBscript or the COM Module with the "WindowsInstaller.Installer" is OK. 可以将VBscript或COM模块与“ WindowsInstaller.Installer”一起使用。 Knowing the way how to to convert it, I would also write a small C++ program doing performing the changes and setting the appropriate information and conversion. 知道如何进行转换,我还将编写一个小型C ++程序来执行更改并设置适当的信息和转换。

I need to command line to, to integrate the MSM conversion into our build process. 我需要通过命令行将MSM转换集成到我们的构建过程中。

What I searched and found: 我搜索和发现的内容:

I saw some tools like ORCA and other MSI tools in the SDK, but none of some are doing what I need. 我在SDK中看到了一些工具,例如ORCA和其他MSI工具,但是没有一个工具可以满足我的需求。 ORCA can save an MSM as a MSI file but I can't see options doing this on the command line. ORCA可以将MSM保存为MSI文件,但是在命令行上看不到执行此操作的选项。

Note: I found an old tool msm2msi, but it doesn't work with my MSM file and crashes, and there is no source available. 注意:我找到了一个旧工具msm2msi,但是它不适用于我的MSM文件并崩溃,并且没有可用的源。

Edit About the changes we apply: 编辑关于我们应用的更改:

The reasons for the change are simple. 更改的原因很简单。 The thirdparty module has a "so called server mode" usually it is only used on 1 machine, but the MSM enables it for every machine. 第三方模块具有“所谓的服务器模式”,通常仅在一台计算机上使用,但是MSM会在每台计算机上启用该模块。 So wie decided to disable it, in changing a property. 因此wie决定在更改属性时将其禁用。 And some more changes. 还有更多变化。

So it is more about the primary installation. 因此,它更多地与主要安装有关。 When an update comes, this settings are never touched. 更新到来时,将永远不会触碰此设置。

Also the MSM installs its own UI, that we don't want and need. 另外,MSM会安装自己不需要的UI。 All controlling is done through our software... So we install the components but we remove that menu entries in the Start folder. 所有控制都是通过我们的软件完成的...因此,我们安装了组件,但删除了Start文件夹中的菜单项。

Any MSI Tool can consume an MSM file and compile a MSI from it, with whatever additional constructs you want - conceivably also the changes you make to the MSM? 任何MSI工具都可以使用MSM文件并从中编译MSI ,还可以使用所需的任何其他结构-可以想象您对MSM所做的更改?

The free and open source WiX Toolkit would certainly be able to compile an MSI from an MSI via the command line, and it is free and open source as well. 免费和开放源代码的WiX Toolkit当然可以通过命令行从MSI编译MSI,它也是免费和开放源代码的。 WiX Quick Start Suggestions . WiX快速入门建议

However, there is cause for concern with regards to the modifications you intend to make in the MSM . 但是,您打算在MSM中进行的修改会引起您的担忧。 This is very bad news indeed, since MSM files are specifically made to not be change by end users. 实际上,这确实是一个坏消息,因为MSM文件是专门为最终用户所更改的。 It would be very good if you can find an alternative way to do the changes needed, for example custom actions inside the MSI file you compile. 如果您能找到一种替代方法来进行所需的更改,例如在编译的MSI文件中进行自定义操作,那将是非常好的。

Although WiX is quite involved at times to deal with, merging and MSM could not be simpler: 尽管有时需要大量地处理WiX,但合并和MSM却不那么简单:

<DirectoryRef Id="TARGETDIR">
    <Merge Id="VCRedist" SourceFile="MySourceFiles\Microsoft_VC80_CRT_x86.msm" DiskId="1" Language="0"/>
</DirectoryRef>

<Feature Id="VCRedist" Title="Visual C++ 8.0 Runtime" AllowAdvertise="no" Display="hidden" Level="1">
    <MergeRef Id="VCRedist"/>
</Feature>

Full sample here: How To: Install the Visual C++ Redistributable with your installer . 完整示例在这里: 如何:使用安装程序安装Visual C ++ Redistributable And the documentation: Merge Element . 和文档: Merge Element

Why do you want to merge this MSM every time? 为什么每次都要合并此MSM? Is it continually updated? 它会不断更新吗? If so, can the vendor change it so that you do not need to post process it? 如果是这样,供应商可以更改它,以便您不需要后处理它吗? If it is not updated, can you just change the MSM itself? 如果未更新,您是否可以更改MSM本身? Not great to do - in fact quite terrible - but it might be less error prone than continuously fiddling with its settings. 做起来并不好-实际上很糟糕-但与不断修改设置相比,它更容易出错。

Transforms & msiexec.exe : With your updated information I would say that you can solve all of this by using a transform, or possibly even by setting a property via the installation command line. Transforms&msiexec.exe :使用更新的信息,我想说您可以通过使用转换,甚至可能通过安装命令行设置属性来解决所有这些问题。

Transforms allow you to change "anything" in an MSI / MSM (they are little database fragments applied at runtime to change the MSI / MSM), setting a PUBLIC PROPERTY (always uppercase) allows you to affect whatever that property is designed to affect. 转换允许您更改MSI / MSM中的“任何内容”(在运行时应用了很少的数据库片段来更改MSI / MSM),设置PUBLIC PROPERTY(始终为大写)可以影响该属性设计的任何影响。 So the latter is a "light weight" customization of the MSI / MSM added and supported by the vendor, that is great when available but in my experience rarely sufficient (typical use is to add a license key or a server IP or URL or install only part of the MSI - a few features - simple stuff like that). 因此,后者是由供应商添加并支持的MSI / MSM的“轻量级”自定义,虽然自定义很好,但根据我的经验很少(通常用于添加许可证密钥或服务器IP或URL或安装) MSI的一部分-一些功能-类似的简单内容)。

Descriptions of how to use transforms or the msiexec.exe command line to customize an MSI installation can be found here: 可以在下面找到有关如何使用transformsmsiexec.exe命令行来自定义MSI安装的说明:


GUI : I really don't understand what you refer to when the MSM "installs in its own GUI"? GUI :当MSM“安装在其自己的GUI中”时,我真的不明白您指的是什么? Hopefully this is just a shortcut to launch an executable from the start menu? 希望这只是从开始菜单启动可执行文件的快捷方式吗? If so you can easily remove it using a transform. 如果是这样,您可以轻松地使用转换将其删除。


Create Transform : You can create transforms using Orca (MS SDK tool) or any other MSI Deployment Tool , or you can create it programatically using the MSI API ( Win32, COM, .NET ). 创建转换 :可以使用Orca (MS SDK工具)或任何其他MSI部署工具来创建转换,也可以使用MSI APIWin32,COM,.NET )以编程方式创建转换。

  • COM Automation : The Microsoft MSI SDK contains a VBScript called WiGenXfm.vbs . COM自动化Microsoft MSI SDK包含一个名为WiGenXfm.vbsVBScript You will have it installed if you got Visual Studio installed. 如果安装了Visual Studio,则将安装它。 You could also find it on github.com (but get it from your own disk to be sure). 您也可以在github.com上找到它(但是请确保从您自己的磁盘上获取它)。

  • DTF / .NET is a component of WiX which allows you to access the MSI API via managed code. DTF / .NET是WiX的组件,它使您可以通过托管代码访问MSI API。 The interop is done for you. 互操作已为您完成。 Sample here . 样品在这里

  • C++ / Win32 : And down-to-the-metal Win32 (accept no substitute - layers be gone :-)). C ++ / Win32和底层的Win32 (不接受替代品-层消失了:-))。


Note : DTF is installed as part of the WiX toolkit . 注意 :DTF是作为WiX工具包的一部分安装的。 The open source toolkit capable of building MSI files ( quick start suggestions ). 能够构建MSI文件的开源工具包( 快速入门建议 )。 After installation find the dll's in the WiX installation folder under %ProgramFiles (x86)% . 安装后,在%ProgramFiles (x86)%下的WiX安装文件夹中找到dll。 Sub folder " bin ". 子文件夹“ bin ”。 File descriptions here . 在此处进行文件描述 And I will end with a quick sample of DTF in action getting some properties from an MSI file. 最后,我将简要介绍DTF的实际使用 ,以从MSI文件中获取一些属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM