;;=====================================================================================----- 
;; 
;;FUNCTION       HWInfo() - DEPRECATED in ITCG CODING - SEE WMISysInfo() 
;; 
;;ACTION         Returns an array containing system hardware configuration 
;;               information from local or remote system 
;; 
;;AUTHOR         Glenn Barnas 
;; 
;;VERSION        1.0  - 2002/03/08 
;; 
;;HISTORY        1.0  - 2002/03/08 - Initial Release 
;; 
;;SYNTAX         HWInfo([hostname][, pAuth]) 
;; 
;;PARAMETERS     Hostname - Optional - String 
;;               - Parameter defining target system to obtain information from. 
;; 
;;               pAuth - Optional - Object 
;;               - Pre-authenticated WMI object pointer 
;; 
;;REMARKS        ERROR is set to 0 if success, actual error otherwise. 
;; 
;;RETURNS        20 element array 
;;               HWInfo[0]  System Brand 
;;               HWInfo[1]  System Model 
;;               HWInfo[2]  System S/N 
;;               HWInfo[3]  System BIOS Revision 
;;               HWInfo[4]  Processor Type 
;;               HWInfo[5]  Processor Speed 
;;               HWInfo[6]  Processor Count 
;;               HWInfo[7]  Physical Memory 
;;               HWInfo[8]  Fixed-Disk Labels, null if none 
;;               HWInfo[9]  Fixed-Disk Mount Point ("d:\" for drives, path for mounted volumes) 
;;               HWInfo[10] Fixed-Disk Drives (A:-Z:, or "MV:" for mounted Volumes) 
;;               HWInfo[11] Fixed-Disk Capacities, bytes 
;;               HWInfo[12] Fixed-Disk FreeSpace, bytes 
;;               HWInfo[13] CD-ROM Disk List 
;;               HWInfo[14] Processor ID (unreliable / in development) 
;;               HWInfo[15] Net Drives 
;;               HWInfo[16]  
;;               HWInfo[17]  
;;               HWInfo[18]  
;;               HWInfo[19]  
;; 
;;DEPENDENCIES   WMIQuery(), WMIConfirm() 
;;               Requires WMI support on the O/S 
;; 
;;TESTED WITH    W2K3, W2K, WXP 
;; 
;;EXAMPLES       $aInfo = HWInfo('hostname')       ; returns remote host info 
;;               $aInfo = HWInfo()                 ; returns local host info 
 
Function HWInfo(OPTIONAL $_Target, OPTIONAL $_pAuth)
 
  Dim $_HW_00, $_HW_01, $_HW_02, $_HW_03, $_HW_04
  Dim $_HW_05, $_HW_06, $_HW_07, $_HW_08, $_HW_09
  Dim $_HW_10, $_HW_11, $_HW_12, $_HW_13, $_HW_14
  Dim $_HW_15, $_HW_16, $_HW_17, $_HW_18, $_HW_19
  Dim $_, $_WinDir, $_aTmp, $_Error, $_OSVer, $_P1, $_P2, $_P3
 
  If VarType($_Target) <> 8		; Make sure the optional host name is a string! 
    $_Target = ''
  EndIf
 
  ; $_Target defines local machine (null) or remote server name 
  $_Target =  IIf(CStr($_Target) <> '', Join(Split(CStr($_Target), '\'), '', 3), '.')
 
  ; verify that WMI is available 
  If WMIConfirm($_Target, $_pAuth)
 
    $_OSVer = CDbl(ReadValue('\\' + $_Target + '\HKEY_Local_Machine\SOFTWARE\Microsoft\Windows NT\CurrentVersion', 'CurrentVersion'))
 
    ; Queries via WMI 
    $_HW_00 = WMIQuery('Manufacturer', 'Win32_ComputerSystem', $_Target, '', '', '', $_pAuth)
    $_Error = IIf(@ERROR, 1, $_Error)
    $_HW_01 = WMIQuery('Model', 'Win32_ComputerSystem', $_Target, '', '', '', $_pAuth)
    $_Error = IIf(@ERROR, 1, $_Error)
    $_HW_02 = WMIQuery('SerialNumber', 'Win32_BIOS', $_Target, '', '', '', $_pAuth)
    $_Error = IIf(@ERROR, 1, $_Error)
    $_HW_03 = WMIQuery('Version', 'Win32_BIOS', $_Target, '', '', '', $_pAuth)
    $_Error = IIf(@ERROR, 1, $_Error)
    $_aTmp  = WMIQuery('SMBIOSBIOSVersion', 'Win32_BIOS', $_Target, '', '', '', $_pAuth)
    $_Error = IIf(@ERROR, 1, $_Error)
    $_HW_04 = WMIQuery('Caption', 'Win32_Processor', $_Target, '', '', '', $_pAuth)
    $_Error = IIf(@ERROR, 1, $_Error)
    $_HW_05 = WMIQuery('CurrentClockSpeed', 'Win32_Processor', $_Target, '', '', '', $_pAuth)
    $_Error = IIf(@ERROR, 1, $_Error)
    $_HW_06 = WMIQuery('NumberOfProcessors', 'Win32_ComputerSystem', $_Target, '', '', '', $_pAuth)
    $_Error = IIf(@ERROR, 1, $_Error)
    $_HW_07 = WMIQuery('TotalPhysicalMemory', 'Win32_ComputerSystem', $_Target, '', '', '', $_pAuth)
    $_Error = IIf(@ERROR, 1, $_Error)
 
    ; If the O/S is XP or older, use the LogicalDisk class 
    If $_OSVer < 5.2
 
      ; The next 5 blocks obtain Logical Disk information (Drive Label, Mount Point, Letter, Capacity, and FreeSpace) 
      ; DRIVE LABELS 
      $_HW_08 = Join(WMIQuery('VolumeName', 'Win32_LogicalDisk', $_Target, 'DriveType', '3', '', $_pAuth), ',')
      $_Error = IIf(@ERROR, 1, $_Error)
      ; MOUNT POINTS 
      $_HW_09 = Join(WMIQuery('Name', 'Win32_LogicalDisk', $_Target, 'DriveType', '3', '', $_pAuth), ',')
      $_Error = IIf(@ERROR, 1, $_Error)
      ; DRIVE LETTERS 
      $_HW_10 = Join(WMIQuery('DeviceID', 'Win32_LogicalDisk', $_Target, 'DriveType', '3', '', $_pAuth), ',')
      $_Error = IIf(@ERROR, 1, $_Error)
      ; VOLUME SIZE 
      $_HW_11 = Join(WMIQuery('Size', 'Win32_LogicalDisk', $_Target, 'DriveType', '3', '', $_pAuth), ',')
      $_Error = IIf(@ERROR, 1, $_Error)
      ; VOLUME FREESPACE 
      $_HW_12 = Join(WMIQuery('FreeSpace', 'Win32_LogicalDisk', $_Target, 'DriveType', '3', '', $_pAuth), ',')
      $_Error = IIf(@ERROR, 1, $_Error)
 
    Else	; use the Volume class 
 
      ; The next 5 blocks obtain Logical Disk information (Drive Label, Mount Point, Letter, Capacity, and FreeSpace) 
      ; DRIVE LABELS 
      $_HW_08 = Join(WMIQuery('Label', 'Win32_Volume', $_Target, 'DriveType', '3', '', $_pAuth), ',')
      $_Error = IIf(@ERROR, 1, $_Error)
      ; MOUNT POINTS 
      $_HW_09 = Join(WMIQuery('Name', 'Win32_Volume', $_Target, 'DriveType', '3', '', $_pAuth), ',')
      $_Error = IIf(@ERROR, 1, $_Error)
      ; DRIVE LETTERS 
      $_HW_10 = Join(WMIQuery('DriveLetter', 'Win32_Volume', $_Target, 'DriveType', '3', '', $_pAuth), ',')
      $_Error = IIf(@ERROR, 1, $_Error)
      ; VOLUME SIZE 
      $_HW_11 = Join(WMIQuery('Capacity', 'Win32_Volume', $_Target, 'DriveType', '3', '', $_pAuth), ',')
      $_Error = IIf(@ERROR, 1, $_Error)
      ; VOLUME FREESPACE 
      $_HW_12 = Join(WMIQuery('FreeSpace', 'Win32_Volume', $_Target, 'DriveType', '3', '', $_pAuth), ',')
      $_Error = IIf(@ERROR, 1, $_Error)
    EndIf
 
    ; convert CDROM drive array to a space-delimited string 
    $_HW_13 = Join(WMIQuery('DeviceID', 'Win32_LogicalDisk', $_Target, 'DriveType', '5', '', $_pAuth), ',')
    $_Error = IIf(@ERROR, 1, $_Error)
 
    ; return a "generic" processor type 
    $_P1 = WMIQuery('Level', 'Win32_Processor', $_Target, '', '', '', $_pAuth)[0]
    $_P2 = WMIQuery('Family', 'Win32_Processor', $_Target, '', '', '', $_pAuth)[0]
    $_P3 = WMIQuery('Stepping', 'Win32_Processor', $_Target, '', '', '', $_pAuth)[0]
    Select
      Case $_P1 = 4
        $_HW_14 = '486'
      Case $_P1 = 5
        $_HW_14 = 'P'
      Case $_P1 = 6 And $_P2 = 1
        $_HW_14 = 'PP' 
      Case $_P1 = 6 And $_P2 < 7
        $_HW_14 = 'P2' 
      Case $_P1 = 6 And $_P2 > 6
        $_HW_14 = 'P3' 
      Case $_P1 = 15 And $_P2 < 5
        $_HW_14 = 'P4' 
    EndSelect
  Else
    $_Error = 120
  EndIf
 
 
  ; Prepare the array to be returned 
  If $_Error = 0
    ; Remove null values from drive lists 
    $_HW_08 = Fill_Array($_HW_08, '-')
    $_HW_09 = Fill_Array($_HW_09, '-')
    $_HW_10 = Fill_Array($_HW_10, 'MV:')
    $HWInfo = $_HW_00[0], $_HW_01[0], $_HW_02[0], $_HW_03[0] + ' [' + $_aTmp[0] + ']', $_HW_04[0], $_HW_05[0], $_HW_06[0], $_HW_07[0], $_HW_08, $_HW_09, $_HW_10, $_HW_11, $_HW_12, $_HW_13, $_HW_14, $_HW_15, $_HW_16, $_HW_17, $_HW_18, $_HW_19
  Else
    $HWInfo = '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''
  EndIf
 
  Exit $_Error
 
EndFunction
 
 
; Fill null values of an array with a specified string 
Function Fill_Array($_String, $_Fill)
  Dim $_, $_aTmp
  $_aTmp = Split($_String, ',')
  For $_ = 0 to UBound($_aTmp)
    If $_aTmp[$_] = ''
      $_aTmp[$_] = $_Fill
    EndIf
  Next
 
  $Fill_Array = Join($_aTmp, ',')
 
EndFunction