为什么枚举已安装的 MSI 包这么慢? [英] Why is enumerating installed MSI packages so slow?

查看:37
本文介绍了为什么枚举已安装的 MSI 包这么慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是此问题的后续内容.

我正在使用这个稍微修改过的脚本来枚举所有已安装的 MSI 包:

I'm using this slightly modified script to enumerate all installed MSI packages:

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & _
    "{impersonationLevel=impersonate}!\\" & _
    strComputer & _
    "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Product")   

If colSoftware.Count > 0 Then
    For Each objSoftware in colSoftware
        WScript.Echo objSoftware.Caption & vbtab & _
        objSoftware.Version
    Next
Else
    WScript.Echo "Cannot retrieve software from this computer."
End If

然而,令人惊讶的是它糟糕的表现.在我的 XP 机器上枚举 34 个已安装的 MSI 包需要 3 到 5 分钟!

What is surprising however, is its abysmal performance. Enumerating the 34 installed MSI packages on my XP box takes between 3 and 5 minutes !

相比之下,旁边的 Linux 机器需要 7 秒才能枚举 1400+ RPM...sigh

By comparison, the Linux box that sits besides is taking 7s to enumerate 1400+ RPMs... sigh

有任何线索吗?

推荐答案

极其缓慢是枚举 Win32_Products 的已知/常见问题

Extreme slowness is a known/common problem for enumerating Win32_Products

如果您需要替代解决方案,请考虑使用卸载"注册表项构建您自己的产品列表(如 您提到的原始问题).

If you need an alternate solution, consider building your own list of products using the 'Uninstall' registry entries (as suggested in one of the answers to the original question you referred to).

枚举卸载的一些一般参考:

Some general references for enumerating Uninstall:

远程进行操作,请使用 WMI 注册表类,StdRegProv.TechNet 甚至方便地提供了一个使用 StdRegProv 做您想做的事情的简单示例:如何列出给定机器上所有已安装的应用程序

And to do it remotely, use the WMI registry class, StdRegProv. TechNet even conveniently provides a simple example of using StdRegProv to do the very thing you want: How do I list all the installed applications on a given machine

这篇关于为什么枚举已安装的 MSI 包这么慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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