尝试从 WIX msi 运行嵌入式工具以进行选择性安装 [英] Attempting to run embedded tool from WIX msi for selective installation

查看:27
本文介绍了尝试从 WIX msi 运行嵌入式工具以进行选择性安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我正在尝试构建一个 WIX msi,它可以运行 devcon.exe(Windows 硬件管理器的命令行版本)来检测是否安装了特定的硬件.如果是,则安装msi A,否则安装msi B(A和B已经作为单独的msi包存在,我们需要根据硬件自动选择安装).

Basically I'm trying to build a WIX msi that can run devcon.exe (command line version of windows hardware manager) to detect if a particular piece of hardware is installed. If it is, then install msi A, else install msi B (A and B already exist as separate msi packages, we need automatic selective installation based on the hardware).

目前我已经安装了 WIX SDK 并创建了一个正确构建 msi 的 WIX 项目.我可以做一些简单的事情,比如执行 CustomActions 来打开 notepad.exe,那种简单的事情.

Currently I've installed the WIX SDK and have created a WIX project that correctly builds an msi. I can do simple things like execute CustomActions to open notepad.exe, that kind of simple things.

第一个问题:我不知道如何将文件打包到安装程序中,而该文件不会安装到目录中.我找到了对它的引用,但没有任何地方明确说明如何去做.如果不打算将其安装到主机驱动器上,我不必将其放在目录"标签中,对吗?

1st problem: I'm having trouble finding out how to package a file into the installer that isn't going to be installed into a directory. I've found references to it, but nowhere that explicitly states how to do it. I don't have to put it inside 'Directory' tags, if it's not going to be installed onto the host drive, right?

第二个问题:devcon.exe 没有(据我所知,如果我错了,请纠正我)似乎根据它找到的内容改变它的返回值,可能是因为它做了很多事情而不是仅限于硬件设备是否存在.因此,如果我可以将它嵌入并运行,那么我需要以某种方式将它输出的内容带到标准输出流,然后将其解析为我正在寻找的特定值.

2nd problem: devcon.exe doesn't (from what I can tell, correct me if I'm wrong) seem to change it's return value depending on what it finds, probably because it does so many things and isn't restricted to whether a hardware device exists or not. So if I can get it embedded and get it to run, then I need to somehow take what it outputs to the standard output stream, and then parse it for the particular values that I'm looking for.

当然这会更容易一些,因为我已经有了一个可以进行解析并设置环境变量的批处理文件,它会告诉我我需要知道什么,但是,如果我可以同时嵌入它们,如何我如何获取批处理文件以引用嵌入的 devcon.exe,然后让 WIX 读取变量,或者我可以在 WIX 中设置一个(或一个属性),然后从批处理文件中设置它?

Of course it would be a bit easier because I've already got a batch file that can do the parsing and set an environment variable which will tell me what I need to know, but, if I can embed them both, how do I get the batch file to reference the embedded devcon.exe, and then get WIX to read the variable, or perhaps I can set one up (or a property) in WIX and then set it from the batch file?

也许我应该创建一个 dll 自定义操作?是否可以从 dll 自定义操作运行嵌入式可执行文件?然后我可以运行 devcon.exe,并在那里完成所有的解析,然后简单地设置一个 Wix 变量或属性来选择下一步做什么.

Maybe I should create a dll custom action instead? Is it possible to run an embedded executable from a dll custom action? Then I could run devcon.exe, and do all the parsing in there, then simply set a Wix variable or Property to choose what to do next.

第三个问题:能够从另一个运行一个 msi.我还不太了解这一点,但我发现 (http://softwareinstall.blogspot.com/2008/06/fun-with-msiembeddedchainer.html) 看起来很有希望,尽管我还没有通读所有内容然而.一次一个问题,我当然已经受够了:)

3rd problem: being able to run one msi from another. I'm not quite upto this yet, but I've found (http://softwareinstall.blogspot.com/2008/06/fun-with-msiembeddedchainer.html) which looks promising, although I haven't read through it all yet. One problem at a time, I've certainly got enough already :)

推荐答案

对于第二个问题,我会创建一个 EXE 或 DLL 自定义操作来启动 devcon.exe,读取其输出并解析它.devcon.exe本身可以存放在EXE/DLL的资源中,并在启动前解压到一个临时目录,用完后删除.

For the 2nd problem, I'd create an EXE or DLL custom action which starts devcon.exe, reads its output and parses it. The devcon.exe itself could be stored in resources of EXE/DLL and extracted into a temporary directory before starting, then you remove it when done with it.

如果选择 DLL,则可以更改 MSI 公共属性.这样你就可以设置一个属性来控制接下来将在 MSI 中做什么.

If you choose DLL, you can change MSI public properties. That way you can set a property which will control what will be done next in the MSI.

如果您选择 EXE,您所拥有的只是退出代码.据我所知,实际上在 MSI 中您无能为力.

If you choose EXE, all you have is exit code. As far as I know there's not much you can do with it actually in MSI.

不建议链接 MSI 安装.您可以将两个驱动程序嵌入到一个包中,并根据 devcon.exe 检测结果设置的属性选择要安装的组件.

Chaining MSI installs is not recommended. You can embed both drivers into one package and select which components to install depending on the property set as the result from devcon.exe detection.

另一种方法是创建一个引导程序 EXE,它运行 devcon.exe 并确定要安装的包.然后它只需安装正确的 MSI 包.

Another approach would be to create a bootstrapper EXE which runs devcon.exe and determines which package to install. Then it simply installs the correct MSI package.

这篇关于尝试从 WIX msi 运行嵌入式工具以进行选择性安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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