Windows Tip Sheet

What Software's in Your Box?

Hard to believe, but even scripting has its weaknesses -- particularly if you need a list of all your computer's installed software.

A reader on ScriptingAnswers.com asked why the WMI Win32_Product class doesn't seem to list every installed software product on Windows machines. Here's a sample script, which should work on WinXP, you can run to see what I'm talking about:

On Error Resume Next
Dim strComputer
Dim objWMIService
Dim propValue
Dim objItem
Dim SWBemlocator
Dim UserName
Dim Password
Dim colItems

strComputer = "."
UserName = ""
Password = ""
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer
  (strComputer,"root\CIMV2",UserName,Password)
Set colItems = objWMIService.ExecQuery("Select *
  from Win32_Product",,48)
For Each objItem in colItems
   WScript.Echo "Caption: " & objItem.Caption
   WScript.Echo "Description: " & objItem.Description
   WScript.Echo "IdentifyingNumber: " &
     objItem.IdentifyingNumber
   WScript.Echo "InstallDate: " & objItem.InstallDate
   WScript.Echo "InstallDate2: " & objItem.InstallDate2
   WScript.Echo "InstallLocation: " & objItem.InstallLocation
   WScript.Echo "InstallState: " & objItem.InstallState
   WScript.Echo "Name: " & objItem.Name
   WScript.Echo "PackageCache: " & objItem.PackageCache
   WScript.Echo "SKUNumber: " & objItem.SKUNumber
   WScript.Echo "Vendor: " & objItem.Vendor
   WScript.Echo "Version: " & objItem.Version
Next

If you run this and compare it to what's in Add/Remove Programs, you'll likely spot things in the GUI that the script doesn't list. So what gives? The problem is that, even in this day and age, software applications exist which don't use the Windows Installer service to install themselves. Win32_Product really only asks Windows Installer to give up the list of what's installed; if Windows Installer didn't install something, then it doesn't know about it, and so the script doesn't detect it. There's unfortunately nothing you can do about this except to bug vendors to repackage their software to use Windows Installer.

About the Author

Don Jones is a multiple-year recipient of Microsoft’s MVP Award, and is an Author/Evangelist for video training company Pluralsight. Don is also a co-founder and President of PowerShell.org, a community dedicated to Microsoft’s Windows PowerShell technology. Don has more than two decades of experience in the IT industry, and specializes in the Microsoft business technology platform. He’s the author of more than 50 technology books, an accomplished IT journalist, and a sought-after speaker and instructor at conferences worldwide. Reach Don on Twitter at @concentratedDon, or on Facebook at Facebook.com/ConcentratedDon.

comments powered by Disqus

SharePoint Watch

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.