Task: create a text file report into which, via VBS (VisualBasic Script), we can export a list of software installed on the given computer (though only the software visible via "Add or Remove Programs").
For example, this file can be dropped onto a server somewhere and analyzed for differences by some third-party system, and when differences are found, it can ping the sysadmin - hey, the set of software over there has changed!
The method isn't mine, I read about it somewhere a while back. Here is the script itself, which can be saved as a VBS file and run.
strHost = "."
Const HKLM = &H80000002
Set objReg = GetObject("winmgmts://" & strHost & _
"/root/default:StdRegProv")
Const strBaseKey = _
"Software\Microsoft\Windows\CurrentVersion\Uninstall\"
objReg.EnumKey HKLM,strBaseKey,arrSubKeys
For Each strSubKey In arrSubKeys
intRet = objReg.GetStringValue(HKLM,strBaseKey & strSubKey,_
"DisplayName",strValue)
If intRet <> 0 Then
intRet = objReg.GetStringValue(HKLM,strBaseKey & strSubKey,_
"QuietDisplayName",strValue)
End If
If (strValue <> "") and (intRet = 0) Then
set fs = CreateObject("Scripting.FileSystemObject")
logfile = "C:\SomeFolder\InstalledSoft.txt"
set handle = fs.OpenTextFile(logfile,8,true)
softwareName = strValue
handle.WriteLine softwareName
handle.close
End If
Next
The report will be created in the file C:\SomeFolder\InstalledSoft.txt. Make sure the user account under which the script is run has sufficient write permissions to that folder.
Comments