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
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
Comment