Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is enumerating installed MSI packages so slow?

This is a follow up from this question.

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

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

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

Any clues on this ?

like image 700
bltxd Avatar asked Jan 20 '26 02:01

bltxd


2 Answers

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:

  • TechNet VBScript example: List Installed Software
  • Microsoft KB: How to enumerate the software products that can be uninstalled on a computer

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

like image 110
Daryn Avatar answered Jan 22 '26 17:01

Daryn


Win32_Product WMI class is so slow because it is doing a Consistency Check - processing every package using Msiexec.exe - everytime you use it.

Check out the issues and vbscript code to do it using a better method at this page: http://csi-windows.com/toolkit/288-win32product-wmi-class-replacement

like image 33
CSI-Windows.com Avatar answered Jan 22 '26 18:01

CSI-Windows.com



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!