~No Rules Volleyball Greater New Orleans .NET User Group (GNONUG) "KNOW .NET"
      Programming    Blogs    Data    Tool    Visual Studio.NET    C#    Other    .NET Framework    .NET Components    ADO.NET    Utility

GNONUG
Mission
Events
Discuss
Resource
Support
Links
Training



How do I use WMI to query installed applications?

Posted by on Monday, March 01, 2004 (PST)

How do you use WMI to query installed applications. Well, below you will find a simple MSInstall only solution and a link to an article with a more elaborate solution.

From Devx

http://www.devx.com/GetHelpOn/10MinuteSolution/16914/0/page/1

 

From Manny:

Not the most elegant, but I use ADO to dump a XML recordset to a file.  This example only dumps those products installed using MSInstaller. Copy the code below and add it to your VBS file.  I'll try to make the same thing work with information from the article above.

 

Option Explicit
         Err.Clear
         On Error Resume Next
         Dim refLocator
         Dim refWMI
  Dim sOutputPath ' As string
  sOutputPath = "c:\temp\ProductList.xml"
         Dim colSoftware
         Dim refSoftware
         Dim DataList
         Const adVarChar = 200
         Const MaxCharacters = 255

 WScript.Echo "Collecting Product Data"
         'connect to WMI with an SWbemLocator
         Set refLocator = CreateObject("WbemScripting.SWbemLocator")
        
         Set refWMI = refLocator.ConnectServer()

         'retrieve a collection of installed software in the usual way
         Set colSoftware = refWMI.ExecQuery("Select * from Win32_Product")
         Set DataList = CreateObject("ADOR.Recordset")
         DataList.Fields.Append "Vendor", adVarChar, MaxCharacters
         DataList.Fields.Append "Name", adVarChar, MaxCharacters
         DataList.Fields.Append "Version", adVarChar, MaxCharacters
         DataList.Open
         For Each refSoftware in colSoftware
           DataList.AddNew
           DataList("Vendor") = refSoftware.Vendor
           DataList("Name") = refSoftware.Name
           DataList("Version") = refSoftware.Version
           DataList.Update
         Next
         DataList.Sort = "Vendor, Name"
         DataList.MoveFirst

 WScript.Echo "Saving to " & sOutputPath
 DataList.Save sOutputPath,1


 WScript.Echo "Finished Saving to " & sOutputPath
         Set colSoftware = Nothing
         Set refWMI = Nothing
         Set refLocator = Nothing
         Set DataList = Nothing        


Add Your Comment


Sample Box Add
Stewart's Law of Retroaction: It is easier to get forgiveness than permission. -- Stewart

 

New Events

  • July 2010 GNONUG Meeting
    Patrick LeBlanc
    Profiling Your DB
    Tuesday, July 13, 2010 6:30pm
    New Horizons New Orleans


  • July GNONUG Meeting
    Steve Andrews will be our guest presenter on Monday, July 13 from 6:30 pm - 9:00 pm. This event is open to anyone interested in .Net.

  • (Speaker Idol) June BRDNUG .Net User
    Sponsored by: Sparkhound

    SPEAKER IDOL Format
    1. 5 speakers.
    2. 15 minutes each.
    3. 3 Grueling judges (Billy Jacobs, Jon Dalberg, Mike Huguet)
    4. Audience will choose the winner.
    5. Great prizes!

    Agenda
    5:45 pm - 6:15 pm: General Introduction/Food and Drinks
    6:15 pm - 7:30 pm: The Competition Will Begin
    7:30 pm - until: Open forum for questions



  •  

    New Posts

  • SharePoint admin/developer
    Posted by md3 on Sunday, April 04, 2010 (PST)

  • Baton Rouge .NET positions
    Posted by md3 on Wednesday, June 24, 2009 (PST)

  • Access
    Posted by md3 on Wednesday, September 19, 2007 (PST)


  •  
    Greater New Orleans .NET User Group "KNOW .NET" GNONUG