JSI Tip 8751. How can a script return the CPU Brand String on Windows XP and Windows Server 2003?

Jerold Schulman

December 2, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today

The CPU Brand String is contained in the FriendlyName Value Name under a registry key similar to:

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumACPIGenuineIntel_-_x86_Family_15_Model__0Where _0 is the first CPU, _1 is the second CPU, etc..

Samples

On one of my laptops, FriendlyName at HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumACPIGenuineIntel_-_x86_Family_6_Model_9_0 contains Intel(R) Pentium(R) M processor 1700MHz.

On one of my desktops, FriendlyName contains Intel(R) Xeon(TM) CPU 2.66GHz at:

HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumACPIGenuineIntel_-_x86_Family_15_Model_2_0HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumACPIGenuineIntel_-_x86_Family_15_Model_2_1HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumACPIGenuineIntel_-_x86_Family_15_Model_2_2HKEY_LOCAL_MACHINESYSTEMCurrentControlSetEnumACPIGenuineIntel_-_x86_Family_15_Model_2_3

I have scripted BrandString.bat to return all the FriendlyName data values.

The syntax for using BrandString.bat is:

BrandString VarName

Where VarName is a call directed environment variable that will be set as follows:

If CPU 0 cannot be found, VarName is set to NONE.
If CPU 0 is found, VarName is set to the number of CPUs and VarName0 is set to the CPU 0 FriendlyName.
If additional CPUs are found, VarName1, etc., is set to the appropriate FriendlyName.

BrandString.bat contains:

@echo offif {%1}=={} @echo Syntax: BrandString CPU&goto :EOFset $BrandStringVar=%1set %1=set $BrandStringkey=Nfor /f "Tokens=*" %%a in ('reg query "HKLMSYSTEMCurrentControlSetEnumACPI" /S^|FIND "HKEY_LOCAL_MACHINE"^|Findstr /E /L /C:"_0"') do ( set $BrandStringkey="%%a")If "%$BrandStringkey%" EQU "N" goto errset $BrandStringkey=%$BrandStringkey:_0"="%set /a $BrandStringCPU=0for /f "Tokens=1,2*" %%a in ('reg query %$BrandStringkey% /S^|FIND "FriendlyName"^|FIND "REG_SZ"') do ( set $BrandStringString=%%c call :parse)call set %$BrandStringVar%=%$BrandStringCPU%set $BrandStringCPU=set $BrandStringkey=set $BrandStringString=set $BrandStringVar=goto :EOF:err@echo Brandstring - CPUID NOT found.set $BrandStringkey=set $BrandStringVar=set %1=NONEgoto :EOF:parsecall set %$BrandStringVar%%$BrandStringCPU%=%$BrandStringString%set /a $BrandStringCPU=%$BrandStringCPU% + 1



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like