JSI Tip 9235. How can a script determine the hardware profile that is currently booted?

Jerold Schulman

April 7, 2005

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

Using REG.EXE, built into Windows XP, Windows Server 2003, and later, or installed on Windows 2000 from the Support Tools on the operating system CD-ROM, I have scripted HardwareProfile.bat to return the active hardware profile key number and friendly name.

The syntax for using HardwareProfile.bat is:

call HardwareProfile Number FriendlyName

Where:

Number       is a call directed environment variable that will contain the  of the active profile,             as in HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlIDConfigDBHardware Profiles.FriendlyName is a call directed environment variable that will contain the friendly name of the active profile.

HardwareProfile.bat contains:

@echo offif {%1}=={} @echo Syntax: HardwareProfile Number FriendlyName&goto :EOFsetlocalfor /f "Tokens=2*" %%a in ('reg query "HKLMSYSTEMCurrentControlSetControlIDConfigDB" /V CurrentConfig^|FIND "REG_DWORD"') do ( set /a profile=%%b)set /a profile=%profile% + 10000set profile=%profile:~1%for /f "Tokens=2*" %%a in ('reg query "HKLMSYSTEMCurrentControlSetControlIDConfigDBHardware Profiles%profile%" /V FriendlyName^|Find "REG_SZ"') do ( set FN=%%b)endlocal&set %1=%profile%&set %2=%FN%



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