I am getting ready to install Windows 7 (when it officially releases). I have decided that its time for me to perform a clean install (instead of an upgrade). So before I do that, I want an inventory of all the software installed on my machine. To do that I found the following vb script, that checks your computer and spits out the list of software to an excel sheet. Very useful.
When it starts you will get a message box that notifies you that the script has started. And when its done you will get a message that the script has completed.
Copy the following text into notepad and save the file with a vbs extension (eg: installedSoftwareList.vbs). Double click on the file to run it.
WScript.Echo "Script Started" Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True Set objWorkbook = objExcel.Workbooks.Add() Set objWorksheet = objWorkbook.Worksheets(1) x = 2 objExcel.Cells(1, 1).Value = "Name" objExcel.Cells(1, 2).Value = "Location" objExcel.Cells(1, 3).Value = "Vendor" objExcel.Cells(1, 4).Value = "Version" objExcel.Cells(1, 5).Value ="Computer" strComputer = "." Set objWMIService = _ GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * from Win32_Product") For Each objItem in colItems objWorksheet.Cells(x, 1) = objItem.Name objWorksheet.Cells(x, 2) = objItem.InstallLocation objWorksheet.Cells(x, 3) = objItem.Vendor objWorksheet.Cells(x, 4) = objItem.Version x = x + 1 Next Set objRange = objWorksheet.UsedRange objRange.EntireColumn.Autofit() WScript.Echo "Script Completed"
The following script uses a different source of truth (the registry), instead of the WMI objects to get a list of software installed. I would use both to determine the list of software installed on your computer.
WScript.Echo "Script Started" on error resume next Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE Set objNetwork = CreateObject("Wscript.Network") strComputer = objNetwork.ComputerName Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True Set objWorkbook = objExcel.Workbooks.Add() Set objWorksheet = objWorkbook.Worksheets(1) x = 2 objExcel.Cells(1, 1).Value = "Name" objExcel.Cells(1, 2).Value = "Version" objExcel.Cells(1, 3).Value = "Install Date" objExcel.Cells(1, 4).Value = "Install Location" objExcel.Cells(1, 5).Value = "Install Source" objExcel.Cells(1, 6).Value = "URL" strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" strEntry1a = "DisplayName" strEntry1b = "QuietDisplayName" strEntry2 = "DisplayVersion" strEntry3 = "InstallDate" strEntry4 = "InstallLocation" strEntry5 = "InstallSource" strEntry6 = "URLInfoAbout" Set objReg = GetObject("winmgmts://" & strComputer & _ "/root/default:StdRegProv") objReg.EnumKey HKLM, strKey, arrSubkeys For Each strSubkey In arrSubkeys intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _ strEntry1a, strValue1) If intRet1 <> 0 Then objReg.GetStringValue HKLM, strKey & strSubkey, _ strEntry1b, strValue1 End If objReg.GetStringValue HKLM, strKey & strSubkey, _ strEntry2, strValue2 objReg.GetStringValue HKLM, strKey & strSubkey, _ strEntry3, strValue3 objReg.GetStringValue HKLM, strKey & strSubkey, _ strEntry4, strValue4 objReg.GetStringValue HKLM, strKey & strSubkey, _ strEntry5, strValue5 objReg.GetStringValue HKLM, strKey & strSubkey, _ strEntry6, strValue6 If strValue1 <> "" Then objWorksheet.Cells(x, 1) = strValue1 objWorksheet.Cells(x, 2) = strValue2 objWorksheet.Cells(x, 3) = strValue3 objWorksheet.Cells(x, 4) = strValue4 objWorksheet.Cells(x, 5) = strValue5 objWorksheet.Cells(x, 6) = strValue6 x = x + 1 End If Next strKey = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" For Each strSubkey In arrSubkeys intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _ strEntry1a, strValue1) If intRet1 <> 0 Then objReg.GetStringValue HKLM, strKey & strSubkey, _ strEntry1b, strValue1 End If objReg.GetStringValue HKLM, strKey & strSubkey, _ strEntry2, strValue2 objReg.GetStringValue HKLM, strKey & strSubkey, _ strEntry3, strValue3 objReg.GetStringValue HKLM, strKey & strSubkey, _ strEntry4, strValue4 objReg.GetStringValue HKLM, strKey & strSubkey, _ strEntry5, strValue5 objReg.GetStringValue HKLM, strKey & strSubkey, _ strEntry6, strValue6 If strValue1 <> "" Then objWorksheet.Cells(x, 1) = strValue1 objWorksheet.Cells(x, 2) = strValue2 objWorksheet.Cells(x, 3) = strValue3 objWorksheet.Cells(x, 4) = strValue4 objWorksheet.Cells(x, 5) = strValue5 objWorksheet.Cells(x, 6) = strValue6 x = x + 1 End If Next Set objRange = objWorksheet.UsedRange objRange.EntireColumn.Autofit() WScript.Echo "Script Completed"
1 comment:
This script is perfect for me.... almost. I have been searching all day for a decent script to do this and yours is by far the best. The problem is I need to use it on servers that do not have EXCEL. Is there a easy way to change the script so the output is in a csv file that does not need EXCEL?
Any help would be much appreciated.
Thanks
Post a Comment