(view source code of hardware.vbs as plain text)
Option ExplicitDim intHDUs, intMem, intMod, intCPUsDim colItems, objItem, objWMIServiceDim strComputer, strMsg' Check command line parametersWith WScript.Arguments
If .Named.Count > 0 Then Syntax
Select Case .Unnamed.Count
Case 0
' Default if none specified is local computer (".")strComputer = "."
Case 1
' Command line parameter can either be a computer ' name or "/?" to request online helpstrComputer = UCase( .Unnamed(0) )
if InStr( strComputer, "?" ) > 0 Then Syntax
Case Else
' Maximum is 1 command line parameterSyntax
End Select
End With
' Enable custom error handlingOn Error Resume Next
' Connect to the computerSet objWMIService = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
' Display error number and description if applicableIf Err Then ShowError
' Get the real computer nameSet colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem" )
' Display error number and description if applicableIf Err Then ShowError
For Each objItem in colItems
strComputer = objItem.Name
Next' Header line for screen outputstrMsg = vbCrLf & "Hardware summary for " & strComputer & ":" & vbCrLf & vbCrLf
' Query processor propertiesSet colItems = objWMIService.ExecQuery( "Select * from Win32_Processor" )
' Display error number and description if applicableIf Err Then ShowError
' Prepare display of resultsintCPUs = 0
For Each objItem in colItems
intCPUs = intCPUs + 1
strMsg = strMsg & "Processor"
If colItems.Count > 1 Then
strMsg = strMsg & " " & intCPUs
End If
strMsg = strMsg & vbCrLf & " Name : " _
& Trim( objItem.Name ) & vbCrLf _
& " Manufacturer : " _
& objItem.Manufacturer & vbCrLf _
& " Description : " _
& objItem.Description & vbCrLf _
& " Current Clock Speed : " _
& objItem.CurrentClockSpeed & " MHz" _
& vbCrLf & vbCrLf
Next' Query memory propertiesSet colItems = objWMIService.ExecQuery( "Select * from Win32_MemoryDevice" )
' Display error number and description if applicableIf Err Then ShowError
intMem = 0
intMod = 0
For Each objItem in colItems
intMem = intMem + objItem.EndingAddress - objItem.StartingAddress
intMod = intMod + 1
NextstrMsg = strMsg & "Memory" _
& vbCrLf _& " Memory Modules : " & intMod _
& vbCrLf _& " Total Physical Memory : " & Int( ( intMem + 1023 ) / 1024 ) & " MB" _
& vbCrLf & vbCrLf
' Query harddisk propertiesSet colItems = objWMIService.ExecQuery( "Select * from Win32_DiskDrive where Size>0" )
' Display error number and description if applicableIf Err Then ShowError
' Prepare display of resultsintHDUs = 0
For Each objItem in colItems
intHDUs = intHDUs + 1
strMsg = strMsg & "Harddisk"
If colItems.Count > 1 Then
strMsg = strMsg & " " & intHDUs
End If
strMsg = strMsg & vbCrLf & " Manufacturer : " _
& objItem.Manufacturer & vbCrLf _
& " Model : " _
& objItem.Model & vbCrLf _
& " Size : " _
& Int( ( objItem.Size + 536870912 ) / 1073741824 ) _
& " GB" & vbCrLf & vbCrLf
Next' Query video adapter propertiesSet colItems = objWMIService.ExecQuery( "Select * from Win32_VideoController" )
' Display error number and description if applicableIf Err Then ShowError
' Prepare display of resultsFor Each objItem in colItems
strMsg = strMsg & "Video" & vbCrLf _
& " Name : " _
& objItem.Name & vbCrLf _
& " Description : " _
& objItem.Description & vbCrLf _
& " Video Processor : " _
& objItem.VideoProcessor & vbCrLf _
& " Adapter RAM : " _
& Int( ( objItem.AdapterRAM + 1048575 ) / 1048576 ) _
& " MB" & vbCrLf _
& " Video Mode Description : " _
& objItem.VideoModeDescription & vbCrLf & vbCrLf
Next' Display resultsWScript.Echo strMsg
'DoneWScript.Quit(0)
Sub ShowError()
strMsg = vbCrLf & "Error # " & Err.Number & vbCrLf & _
Err.Description & vbCrLf & vbCrLf
Syntax
End Sub
Sub Syntax()
strMsg = strMsg _ & vbCrLf _& "Hardware.vbs, Version 2.00" _
& vbCrLf _& "Display basic hardware summary for any WMI enabled computer on the network" _
& vbCrLf & vbCrLf _
& "Usage: CSCRIPT.EXE //NoLogo HARDWARE.VBS [ computer ]" _
& vbCrLf & vbCrLf _
& "Where: ""computer"" is an optional remote computer name" _
& vbCrLf _& " (default is the local computer name)" _
& vbCrLf & vbCrLf _
& "Written by Rob van der Woude" _
& vbCrLf _& "http://www.robvanderwoude.com"
WScript.Echo strMsg
WScript.Quit(1)
End Sub
page last modified: 2025-10-11; loaded in 0.0047 seconds