JSI Tip 5403. How can I determine processor make, model, and speed in a batch script?


I first discussed processor speed in tip 1949.

To retrieve processor make, model, and speed, I have scripted CPUMMS.BAT,
using REG.EXE on Windows 2000, from the Windows 2000 Support Tools,
or REG.EXE built into Windows XP.

The syntax for using CPUMMS.BAT is:

call cpumms \[cpu\]

where cpu is an optional CPU number. If you have a multi-processor,
the first processor is 0, the second is 1, etc...
If the cpu parameter is omitted, 0 is used.

The routine returns:

Environment Variable Name   D E S C R I P T I O N
vendor The manufacturer's identification, like GenuineIntel.
model The model information, like x86 Family 6 Model 8 Stepping 1.
MHZ CPU speed, like 800. This is an arithmetic environment variable.

If you enter a cpu parameter that does NOT exist on this computer,
the environment variables are NOT set. The easiest way to test for this is:

if not defined MHZ goto label

CPUMMS.BAT contains:

@echo off
if \{%1\}==\{\} set cpu=0&goto find
set cpu=%1
:find
call :look >>nul 2>>&1
set cpu=
goto :EOF
:look
set vendor=
for /f "Skip=3 Tokens=2*" %%i in ('reg QUERY "HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\%cpu%" /v VendorIdentifier') do set vendor=%%j
set model=
for /f "Skip=3 Tokens=2*" %%i in ('reg QUERY "HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\%cpu%" /v Identifier') do set model=%%j
set MHZ=
for /f "Skip=3 Tokens=2*" %%i in ('reg QUERY "HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\%cpu%" /v ~MHZ') do set /a MHZ=%%j
set cpu=



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish