' FileName: SoftwareMeteringCLS.vbs ' //////////////////////////////////////////////////////////////////// If (WScript.ScriptName = "SoftwareMeteringCLS.vbs") Then Call demo_SoftwareMeteringCLS()
' ==================================================================== Function getSoftwareList(sHost) ' Callable by *.wsf; will return list (safe array) of installed ' software on the sHost system (sHost is ComputerName or IP address). ' ' The assumption is that sHost is available and has WMI installed.
Set oSoftMeter = new SoftwareMeteringCLS sProgsAry = oSoftMeter.getList(sHost) Set oSpftMeter = Nothing getSoftwareList = sProgsAry End Function ' ====================== CLASS ======================================= Class SoftwareMeteringCLS ' Author: Branimir Petrovic ' Date: 6 Sept 2002 ' Version: 1.0.3 ' ' Revision History: ' 30 March 2002 V 1.0.0 ' ' 08 April 2002 V 1.0.1 ' Added error handling - if the target system is not present, ' or does not have WMI, getList(sHost) will return empty list. ' ' Added global function getSoftwareList(sHost) to be used ' from *.wsf scripts when caller script is JScript (since ' JScript can not instantiate VBS classes directly). ' ' 21 April 2002 V 1.0.2 ' Replacing "[" with "(" and "]" with ")" in "DisplayName" ' Some strings like: [See Q311401 for more information] ' can cause troubles, therefore replacement. ' ' 6 Sept 2002 V 1.0.3 ' Win2K's SP3 for Windows 2000 introduced slight (but silent) ' 'improvement' in a way registry provder's EnumValues method ' deals with empty keys. EnumValues method called against ' keys without any values (except the Default, empty value) ' will now return Null value (previously array of size 0 was ' returned). Added (previously unneeded) type checking... ' ' ' Dependancies: ' WSH 5.6 ' ' Methods: ' - getClassName() ' - getVersion() ' - getList(sHost) sHost parameter can be computer name or IP address ' Enumerates all subkeys in: ' "Software/Microsoft/Windows/CurrentVersion/Uninstall" ' Returns array of strings, each string item containing: ' "DisplayNameKeyValue[ --Version: DisplayVersionKeyValue]" ' ' If sHost parameter is empty string or non-string value, ' function returns list of installed software on this host. ' Otherwise it will connect to host pointed to by sHost string ' (provided sufficient level of permissions) ' ' - getHostString() Returns name of the system or IP address
' --- Private data members Private HKLM ' Points to HKEY_LOCAL_MACHINE hive Private UNINSTALL_ROOT ' Software/Microsoft/Windows/CurrentVersion/Uninstall Private SUPRESS_HOTFIX_ENTRIES ' By default is TRUE (set in Class_Initialize) ' (supressess listing of installed hotfixes) Private CLASS_NAME Private VERSION Private REG_SZ Private oReg Private sComputerName