Script to Get Microsoft Product's Installed on Your Machine With Version Number

A few days back I was working on the build machine. Or you can say I needed to release a new build machine installed with some specific software.

To achieve this I wrote a few bat files to install specific software silently.

But to verify that software or an application has been installed I needed to check this through the Control Panel. It was rather a manual process.


So to avoid this manual process I came across a bat file and VBScript file which will list all Microsoft products with version number installed on that particular machine.

First we will write our bat file which we will call our VBScript to list out all the product names with version number. We will say bat file as getListOfMicSoft.bat 
code would be as below:

 
 

echo CompanyName            SoftwareInstalled       VersionNumber>ListOfMicroSoftware.txt echo ================================================>>ListOfMicroSoftware.txt rem location of the vb script file.

cscript //nologo D:\Jawed\GetListOfSoft.vbs >>ListOfMicroSoftware.txt
 

 

Now here is the logic written in VBScript file[GetListOfSoft.vbs] to get all the product details and note down in text file ListOfMicroSoftware.txt.

 
 

On Error Resume Next On Error Resume Next Const strComputerName = "." Const HKLM        = &H80000002 Const strKeyPath  = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Dim oReg, arrSubKeys, strProduct, strDisplayName, strVersion

Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputerName & "\root\default:StdRegProv")

' Enumerate the subkeys of the Uninstall key
oReg.EnumKey HKLM, strKeyPath, arrSubKeys
For Each strProduct In arrSubKeys
  ' Get the product's display name
  oReg.GetStringValue HKLM, strKeyPath & "\" & strProduct, "DisplayName", strDisplayName
  ' Only contain 'Microsoft'
  If InStr(1, strDisplayName, "Microsoft", vbTextCompare) > 0 Then
    ' Get display version
    oReg.GetStringValue HKLM, strKeyPath & "\" & strProduct, "DisplayVersion", strVersion

    WScript.Echo strDisplayName &"======"& vbTab &"===========================================" & strVersion
  End
If
Next
 

 

Click on bat file and it will generate the text file [ListOfMicroSoftware.txt] with all products with version number; the following is the snapshot of that.

Microsoft.jpg
Feel free to provide your comments and feedback.


Similar Articles