'Gets the number of CPU Sockets, Cores, and Logical Processors.  Cocobolo Software LLC April 2014.
'usage: cscript.exe CPUCoreCount.vbs COMPUTERNAME

strComputer = WScript.Arguments(0)

on error resume next
Err.Clear

'strComputer = TextBox.value 'InputBox("Enter the Computer Name or IP address")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

'Get OS Version for CPU info
Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
		For Each objOperatingSystem in colOperatingSystems
			OSVersion = objOperatingSystem.Caption
		Next

'Get Processor Info (note: it can take a long time to pull info from this class)	
Sockets = 0	
Cores = 0
LogicalProcessors = 0
WMISupport = 1

If InStr(OSVersion,"2003") or InStr(OSVersion,"XP") or InStr(OSVersion,"2000") Then
	WMISupport = 0
End If

Set colProc = objWMIService.ExecQuery("Select * from Win32_Processor")
	For Each objProc in colProc 
		ProcessorName = objProc.Name
		Sockets = Sockets + 1
		Cores = Cores + objProc.NumberOfCores
		If Err.Number <> 0 Then
			Cores = Err.Description
			Err.Clear
		End If
		LogicalProcessors = LogicalProcessors + objProc.NumberOfLogicalProcessors
	Next
	
If WMISupport = 0 Then
	LogicalProcessors = Sockets
	Sockets = "Property is not supported for this OS"
	Cores = "Property is not supported for this OS"
End If	

wscript.echo("Sockets: " & Sockets & vbCrLf & "Cores: " & Cores & vbCrLf & "Logical Procs: " & LogicalProcessors)