Software Inventory Database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mpmason14
    New Member
    • Jun 2006
    • 65

    #1

    Software Inventory Database

    I found a vbscript on vbskrypt.com that allows me to inventory the software installed on my computer and puts it in an Access database.

    problem:
    the script only finds those programs installed by Windows Installer - nothing else.

    objective:
    i want to expand the quality of the script to be able to find ALL programs as they are listed in Add/remove programs. part of the script includes the search location as "Win32 Product"...I think that is all that has to be changed in order to search a larger scope, but obviously i am at a loss

    i googled this and found nothing - if anyone can give me a hand i would really appreciate it.

    THIS IS NOT MY SCRIPT - I AM NOT TAKING ANY CREDIT FOR IT


    '============== =============== =============== =============== ===============
    '
    ' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0
    '
    ' NAME: SoftInv.vbs
    '
    ' AUTHOR: Todd Fields , *
    ' DATE : 2005/12/19
    '
    ' COMMENT: Creates a software inventory database
    '
    '============== =============== =============== =============== ===============
    Option Explicit

    ' Declare the constants for the database connection
    Const adOpenStatic = 3
    Const adLockOptimisti c = 3

    ' Declare the variables
    Dim sComputer
    Dim oNet, oWMI, oSoftware
    Dim cnSoftInv, rsData
    Dim colSoftware

    ' This computer
    sComputer = "."

    ' Create an instance of the Network object
    Set oNet = CreateObject("W Script.Network" )

    ' Connect to the WMI provider
    Set oWMI = GetObject("winm gmts:" _
    & "{impersonation Level=impersona te}!\\" & sComputer & "\root\cimv 2")

    ' Query the Win32_Product namespace
    ' to get a collection of the software
    Set colSoftware = oWMI.ExecQuery _
    ("SELECT * FROM Win32_Product")

    ' Create an instance of the ADODB Connection object And
    ' an instance of the Recordset object
    Set cnSoftInv = CreateObject("A DODB.Connection ")
    Set rsData = CreateObject("A DODB.Recordset" )

    ' Set the connection String
    cnSoftInv.Conne ctionString = "Provider=Micro soft.Jet.OLEDB. 4.0;" _
    & "User ID=Admin;Data Source=U:\netwo rk_admin\databa se_play\softwar einv.mdb"

    ' Open the connection
    cnSoftInv.Open

    ' Open the data table
    rsData.Open "software", cnSoftInv, adOpenStatic, adLockOptimisti c

    For Each oSoftware in colSoftware
    ' Add an empty row to the recordset
    rsData.AddNew

    ' Update the fields in the empty row
    ' with software inventory data
    rsData.Fields(" ComputerName"). Value = oNet.ComputerNa me
    rsData.Fields(" Caption").Value = oSoftware.Capti on
    rsData.Fields(" Description").V alue = oSoftware.Descr iption
    rsData.Fields(" IdNum").Value = oSoftware.Ident ifyingNumber
    rsData.Fields(" InstallLocation ").Value = oSoftware.Insta llLocation
    rsData.Fields(" InstallState"). Value = oSoftware.Insta llState
    rsData.Fields(" InstallDate").V alue = oSoftware.Insta llDate
    rsData.Fields(" Name").Value = oSoftware.Name
    rsData.Fields(" PackageCache"). Value = oSoftware.Packa geCache
    rsData.Fields(" SKUNumber").Val ue = oSoftware.SKUNu mber
    rsData.Fields(" Vendor").Value = oSoftware.Vendo r
    rsData.Fields(" Version").Value = oSoftware.Versi on

    ' Update/save the row to the recordset
    rsData.Update
    Next

    ' Close and reset the recordset object
    rsData.Close
    Set rsData = Nothing

    ' Close and reset the connection object
    ' This will also close any open recordsets
    cnSoftInv.Close
    Set cnSoftInv = Nothing
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Assuming from your question, that the Access concepts are happily handled and you just need information as to how to access the information that you want to populate the database with, I'm going to move this thread to the VB forum, in the hope that someone there will have experience in this matter.

    Comment

    • mpmason14
      New Member
      • Jun 2006
      • 65

      #3
      the information IS properly outputted to the Access table, but I want it to gather more than just the information in the Win32 Product name space.

      Comment

      • sashi
        Recognized Expert Top Contributor
        • Jun 2006
        • 1749

        #4
        Originally posted by mpmason14
        the information IS properly outputted to the Access table, but I want it to gather more than just the information in the Win32 Product name space.
        Hi there,

        In order to be able to gather more information you need to know a little bit of Windows Management Instrumentation (WMI) magic, check out MSDN, there are tonnes of notes on WMI, hope it helps. Good luck & Take care.

        Comment

        • mpmason14
          New Member
          • Jun 2006
          • 65

          #5
          i'll try that - thanks

          Comment

          • mpmason14
            New Member
            • Jun 2006
            • 65

            #6
            if anyone is looking for a great "tutorial" on WMI, they can check this site from MSDN - thanks again for suggesting it. i'm much closer to figuring out what it is i have to do...

            http://msdn2.microsoft.com/en-us/library/ms974579.aspx
            Last edited by mpmason14; Nov 29 '06, 09:17 PM. Reason: correction

            Comment

            • sashi
              Recognized Expert Top Contributor
              • Jun 2006
              • 1749

              #7
              Originally posted by mpmason14
              if anyone is looking for a great "tutorial" on WMI, they can check this site from MSDN - thanks again for suggesting it. i'm much closer to figuring out what it is i have to do...

              http://msdn2.microsoft.com/en-us/library/ms974579.aspx
              Hi there,

              It's a great link, thanks a million to you. Good luck & Take care.

              Comment

              Working...