将附加组件安装到 IIS 时,如何验证 IIS WMI 提供程序是否可用?
显然,IIS 的管理部分(IIS WMI 提供程序)可以与 IIS 运行时分开安装。
我想为 IIS 的附加组件生成一个安装程序,并且我知道如何检查 WIX 项目中是否存在 IIS 运行时。但是,安装程序需要执行各种管理操作、WMI 操作,为此它不仅需要 IIS,还需要 IIS 的 WMI 提供程序。正如我所说,可能存在也可能不存在。
在 WIX 项目中,如何检查 IIS WMI 提供程序是否存在,以及如果 IIS WMI 提供程序不存在,如何向用户呈现合理的对话框?
安装程序已经有一些用 Javascript 实现的 MSI 自定义操作,我可以使用
var iis = GetObject("winmgmts:root\WebAdministration");
... 来检查 WMI 提供程序是否存在。如果不存在 WMI 提供程序,它将失败(抛出)。我想我可以使用它来设置属性,然后在 Product.wxs 文件中尽早检查条件中的该属性。
这行得通吗?还有其他建议吗?
Apparently the management piece of IIS - the IIS WMI provider - is installable separately from the IIS runtime.
I'd like to produce an installer for an add-on to IIS, and I know how to check for the existence of the IIS runtime in the WIX project. But, the installer needs to do various management things, WMI things, and for that it needs not only IIS, but the WMI Provider for IIS. Which as I said, may or may not be present.
In a WIX project, How do I check for the existence of the IIS WMI Provider, and how do I present a reasonable dialog to the user if the IIS WMI Provider is not present?
The installer already has a few MSI Custom Actions implemented in Javascript, and I can use
var iis = GetObject("winmgmts:root\WebAdministration");
...to check for the existence of the WMI Provider. It will fail (throw) if no WMI Provider is there. I suppose I could use this to set a Property, and then check that Property in a Condition early on in the Product.wxs file.
is this going to work? any other suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为更好的方法仍然是浏览注册表以进行适当的设置。另一个问题是找到合适的人并不总是那么容易。 :)
例如,我的安装程序需要启用 IIS6 兼容性(对于 IIS 7 计算机),特别是 IIS 6 WMI 兼容性。此设置位于 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Components 下的一个名为 WMICompatibility 的值中。因此,我应该做的就是编写一个 RegistrySearch 元素来搜索该值并检查它是否为 1。
为了找到正确的设置,我将搜索所有 IIS 参数所在的密钥(每个版本的 IIS 可能有所不同,我在这里不确定),启用您需要的 IIS WMI 提供程序并查看注册表中发生了什么变化。我怀疑注册表监控软件在这里可以提供很大帮助。
I suppose the better way for this is still to browse the registry for appropriate setting. Another question is it's not always easy to find the right one. :)
For instance, my installer needs IIS6 compatibility to be enabled (for IIS 7 machines), in particular, IIS 6 WMI compatibility. This setting is located under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Components, in a value called WMICompatibility. So, everything I should do is to author a RegistrySearch element to search for this value and check if it's 1.
In order to find the correct setting, I would search for the key all IIS parameters reside under (it might differ for each version of IIS, I'm not certain here), enable IIS WMI provider you need and see what was changed in registry. I suspect registry monitor software can help here a lot.
是的,通过名字测试对象的实例化是可行的。这是一个合理的策略,比在注册表中进行探索要好。它始终提供正确的结果。只需捕获 WMI 提供程序不可用时发生的异常即可。
Yes, testing instantiation of the object via the moniker is going to work. It's a reasonable strategy, better than spelunking around in the registry. It delivers the right result, all the time. Just catch the exception that occurs if the WMI provider is not available.