Submitted By: Anonymous

Identifies the CPU type on a computer.

Visual Basic
Edit|Remove
wscript.echo CpuID

Function CpuID()
  ' Obtaining CPU identification using WMI
  ' Script author: Torgeir Bakken

  ' Function returns a number of type integer:
  ' 0  ==>  Unknown CPU
  ' 1  ==>  Pentium or Pentium MMX
  ' 2  ==>  Pentium Pro/II or Celeron
  ' 3  ==>  Pentium III
  ' 4  ==>  Pentium 4

  ' based on this table:
  ' Family   Model               Type
  ' 5        <  4                Pentium
  ' 5        >= 4                Pentium MMX
  ' 6        <  3                Pentium Pro
  ' 6        >= 3 < 5            Pentium II
  ' 6        == 5                Pentium II or Celeron
  ' 6        == 6                Celeron
  ' 6        >= 7                Pentium III
  '15        >= 0                Pentium 4

  ' Family 5 and 6 identification based on information from here:
  ' ftp://download.intel.com/support/processors/procid/24161812.pdf

  Dim oWMI, oCpu, sCpuDescr, aCpuDescr, i, iFamily, iModel, iVersion

  Set oWMI = GetObject("winmgmts:")
  For Each oCpu in oWMI.InstancesOf("Win32_Processor")
    sCpuDescr = oCpu.Description
  Next

  aCpuDescr = Split(sCpuDescr)
  For i = 0 to Ubound(aCpuDescr)
    If LCase(aCpuDescr(i)) = "family" Then
      iFamily = CInt(aCpuDescr(i+1))
    End If
    If LCase(aCpuDescr(i)) = "model" Then
      iModel = CInt(aCpuDescr(i+1))
    End If
  Next

  iVersion = (iFamily * 100) + iModel

  Select Case True
    Case iFamily = 5
      ' Pentium or Pentium MMX
      CpuID = 1

    Case iVersion < 607
      ' Pentium Pro/II or Celeron
      CpuID = 2

    Case iFamily = 6
      ' Pentium III
      CpuID = 3

    Case iFamily = 15
      ' Pentium 4
      CpuID = 4

    Case Else
      ' Unknown CPU
      CpuID = 0
  End Select
End Function