Script – Find all installed applications

I had a task to collect all application names installed on a number of servers, including updates.
OSes were both 2003 and 2008, therefore Powershell was not an option, so I went with vbscript.

One important thing I’ve learned while developing was the fact that on 64 bit OSes Windows stores information about the installed software not only in the “SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\” key but also in the “SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\”.

Here is the script.

To run it copy the code to the text file, rename to for example “name.vbs” and then execute in the cmd: “cscript name.vbs > output.txt && output.txt”.

Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
strComputer = "."
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

strEntry1a = "DisplayName"
strEntry1b = "QuietDisplayName"
strEntry2 = "VersionMajor"
strEntry3 = "VersionMinor"

Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")

objReg.EnumKey HKLM, strKey, arrSubkeys
WScript.Echo "Installed Applications" & VbCrLf

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
 If strValue1 "" Then
  objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry2, intValue2
  objReg.GetDWORDValue HKLM, strKey & strSubkey, strEntry3, intValue3
 If intValue2 "" Then
  WScript.Echo strValue1 & " [Version: " & intValue2 & "." & intValue3 & "]"
 Else
 WScript.Echo strValue1
 End If
End If
Next

' When OS is 64 bit, then 32bit applications will be installed as WOW.
strkey64 = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"

objReg.EnumKey HKLM, strKey64, arrSubkeys
WScript.Echo "Installed Applications" & VbCrLf

For Each strSubkey In arrSubkeys
 intRet1 = objReg.GetStringValue(HKLM, strKey64 & strSubkey, strEntry1a, strValue1)
 If intRet1 0 Then
  objReg.GetStringValue HKLM, strKey64 & strSubkey, strEntry1b, strValue1
 End If

 If strValue1 "" Then
  objReg.GetDWORDValue HKLM, strKey64 & strSubkey, strEntry2, intValue2
  objReg.GetDWORDValue HKLM, strKey64 & strSubkey, strEntry3, intValue3
 If intValue2 "" Then
  WScript.Echo strValue1 & " [Version: " & intValue2 & "." & intValue3 & "]"
 Else
  WScript.Echo strValue1
 End If
End If
Next
Advertisements

Leave a Comment here

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s