Skip to content

How to Get the System Manufacturer and Model in Batch Script

Learn how to retrieve Windows system manufacturer, model, and serial number using Batch Script with WMIC, systeminfo, and PowerShell for IT automation, driver deployment, and inventory management.

Identifying the hardware manufacturer and model of a Windows machine is a common requirement for inventory management, automated driver installation, warranty lookups, and conditional logic in deployment scripts. Rather than physically inspecting the label on a laptop or desktop chassis, Batch Script can query this information programmatically through WMI (Windows Management Instrumentation) or the systeminfo command.

In this guide, we will explore multiple methods to retrieve the system manufacturer, model name, and serial number using Batch Script.

Method 1: Using WMIC (The Standard Approach)

The wmic command provides direct access to the Win32_ComputerSystem class, which contains the manufacturer and model properties.

@echo off
setlocal

echo Retrieving System Manufacturer and Model...
echo =============================================

:: Get Manufacturer
set "manufacturer="
for /f "tokens=2 delims==" %%A in ('wmic computersystem get Manufacturer /value 2^>nul ^| find "="') do (
    set "manufacturer=%%A"
)

:: Get Model
set "model="
for /f "tokens=2 delims==" %%A in ('wmic computersystem get Model /value 2^>nul ^| find "="') do (
    set "model=%%A"
)

if not defined manufacturer (
    echo [ERROR] Could not retrieve system information via WMI.
    pause
    exit /b 1
)

echo Manufacturer: %manufacturer%
echo Model:        %model%

pause

Adding the Serial Number (Service Tag)

The serial number (or Service Tag on Dell machines) is stored in a different WMI class: Win32_BIOS.

@echo off
setlocal

echo =============================================
echo       SYSTEM HARDWARE INFORMATION
echo =============================================
echo.

:: Manufacturer
set "mfr="
for /f "tokens=2 delims==" %%A in ('wmic computersystem get Manufacturer /value 2^>nul ^| find "="') do set "mfr=%%A"

:: Model
set "mdl="
for /f "tokens=2 delims==" %%A in ('wmic computersystem get Model /value 2^>nul ^| find "="') do set "mdl=%%A"

:: Serial Number / Service Tag
set "serial="
for /f "tokens=2 delims==" %%A in ('wmic bios get SerialNumber /value 2^>nul ^| find "="') do set "serial=%%A"

:: System SKU (product number on HP machines)
set "sku="
for /f "tokens=2 delims==" %%A in ('wmic computersystem get SystemSKUNumber /value 2^>nul ^| find "="') do set "sku=%%A"

echo Manufacturer:  %mfr%
echo Model:         %mdl%
echo Serial Number: %serial%
echo System SKU:    %sku%

pause

Common Outputs by Manufacturer

Manufacturer Typical Model Output Serial Number Label
Dell Inc. Latitude 5520, OptiPlex 7090 Service Tag
HP HP EliteBook 840 G8 Product ID
Lenovo 20U9CTO1WW (cryptic) Machine Type
Microsoft Corporation Surface Pro 7 Device Serial
VMware, Inc. VMware Virtual Platform VMware-xx-xx

Method 2: Using SYSTEMINFO

The systeminfo command provides manufacturer and model information as part of its comprehensive output. While slower than wmic, it is universally available.

@echo off
setlocal enabledelayedexpansion

echo Parsing systeminfo for hardware details...

:: Run systeminfo once and cache the output to avoid calling it twice
set "tmpfile=%temp%\sysinfo_%RANDOM%.txt"
systeminfo > "%tmpfile%" 2>nul

set "mfr="
set "mdl="
for /f "tokens=1* delims=:" %%A in ('findstr /c:"System Manufacturer" /c:"System Model" "%tmpfile%"') do (
    set "label=%%A"
    set "value=%%B"
    :: Trim leading spaces from the value
    if defined value (
        for /f "tokens=*" %%V in ("!value!") do set "value=%%V"
    )
    echo !label:~0,20!: !value!
)

del "%tmpfile%" 2>nul

pause

Method 3: Getting the Lenovo Friendly Name

As noted above, Lenovo machines report internal part numbers instead of marketing names in the Model field. To get the recognizable name (e.g., "ThinkPad X1 Carbon Gen 9"), query the Win32_ComputerSystemProduct class.

@echo off
setlocal

echo Retrieving Lenovo-friendly model name...

:: The Version field in ComputerSystemProduct contains the marketing name
set "friendly_name="
for /f "tokens=2 delims==" %%A in ('wmic csproduct get Version /value 2^>nul ^| find "="') do set "friendly_name=%%A"

:: Also get the standard model for reference
set "internal_model="
for /f "tokens=2 delims==" %%A in ('wmic computersystem get Model /value 2^>nul ^| find "="') do set "internal_model=%%A"

echo Internal Model: %internal_model%
echo Friendly Name:  %friendly_name%

:: The friendly name may be empty on non-Lenovo hardware
if not defined friendly_name (
    echo.
    echo [INFO] The Version field is empty. This is normal on non-Lenovo hardware.
    echo        Use the Model field instead.
)

pause

On a Lenovo ThinkPad T14 Gen 2, this would output:

Internal Model: 20W0CTO1WW
Friendly Name:  ThinkPad T14 Gen 2

Since Microsoft is gradually deprecating wmic, the modern approach uses PowerShell's Get-CimInstance cmdlet.

@echo off
setlocal enabledelayedexpansion

echo Retrieving hardware info via PowerShell...
echo.

set "mfr="
set "mdl="
set "serial="

for /f "usebackq tokens=1* delims==" %%A in (`powershell -NoProfile -Command ^
  "$cs = Get-CimInstance Win32_ComputerSystem; ^
   $bios = Get-CimInstance Win32_BIOS; ^
   Write-Output ('Manufacturer=' + $cs.Manufacturer); ^
   Write-Output ('Model=' + $cs.Model); ^
   Write-Output ('Serial=' + $bios.SerialNumber)" 2^>nul`) do (
    if "%%A"=="Manufacturer" set "mfr=%%B"
    if "%%A"=="Model" set "mdl=%%B"
    if "%%A"=="Serial" set "serial=%%B"
)

if not defined mfr (
    echo [ERROR] Could not retrieve hardware information via PowerShell.
    pause
    exit /b 1
)

echo Manufacturer: !mfr!
echo Model:        !mdl!
echo Serial:       !serial!

pause

Practical Use Case: Conditional Driver Installation

A common real-world scenario is a deployment script that installs different drivers based on the detected hardware model.

@echo off
setlocal enabledelayedexpansion

:: Get the model
set "model="
for /f "tokens=2 delims==" %%A in ('wmic computersystem get Model /value 2^>nul ^| find "="') do set "model=%%A"

if not defined model (
    echo [ERROR] Could not detect hardware model.
    pause
    exit /b 1
)

echo Detected Model: !model!
set "driver_found=0"

:: Install the correct display driver based on model
echo !model! | findstr /i "Latitude 5520" >nul
if !errorlevel! equ 0 (
    echo Installing Dell Latitude 5520 display driver...
    start /wait "" "drivers\dell5520_display.exe" /s
    set "driver_found=1"
    goto :done
)

echo !model! | findstr /i "EliteBook 840" >nul
if !errorlevel! equ 0 (
    echo Installing HP EliteBook 840 display driver...
    start /wait "" "drivers\hp840_display.exe" /s
    set "driver_found=1"
    goto :done
)

echo !model! | findstr /i "Surface Pro" >nul
if !errorlevel! equ 0 (
    echo Installing Surface Pro display driver...
    start /wait "" "drivers\surface_display.msi" /quiet
    set "driver_found=1"
    goto :done
)

:done
if "!driver_found!"=="0" (
    echo [WARNING] Model "!model!" is not in the driver mapping.
    echo          Skipping driver installation.
)

pause

Common Mistakes

The Wrong Way: Parsing WMIC Output Without /value Format

:: WRONG - Captures the header row and blank lines
for /f %%A in ('wmic computersystem get Manufacturer') do set "mfr=%%A"
echo %mfr%

The Wrong Way: Using SYSTEMINFO Internationally

:: WRONG - Fails on non-English OS
systeminfo | findstr "System Manufacturer"

The string "System Manufacturer" is localized. On a French system, you would need "Fabricant du système". Always use wmic or PowerShell for international deployments.

The Wrong Way: Assuming WMIC Output Has No Trailing Characters

:: WRONG - Stored value contains invisible trailing carriage return
for /f "tokens=2 delims==" %%A in ('wmic computersystem get Manufacturer /value ^| find "="') do set "mfr=%%A"
if "%mfr%"=="Dell Inc." echo Dell detected

Best Practices

  1. Use wmic with /value format: The /value output format (Property=Value) is the easiest to parse reliably in Batch, and piping through find "=" strips header rows and blank lines.
  2. Query csproduct for Lenovo: Always check Win32_ComputerSystemProduct.Version for human-readable Lenovo model names, and fall back to Win32_ComputerSystem.Model on other hardware.
  3. Include the Serial Number: For inventory and warranty scripts, always capture Win32_BIOS.SerialNumber alongside the manufacturer and model.
  4. Transition to PowerShell: As wmic enters deprecation, begin transitioning inventory scripts to use embedded Get-CimInstance calls for forward compatibility.
  5. Initialize variables before WMIC parsing: Always set "var=" before a for /f loop that parses WMIC output. WMIC's trailing carriage returns can cause stale values to persist if the command produces no output.
  6. Use partial matching for model comparisons: Due to WMIC's trailing \r characters, use echo !model! | findstr /i "search string" rather than exact == string comparison. This also handles minor model name variations across BIOS revisions.
  7. Add 2>nul to WMIC commands: Redirect stderr on all wmic calls to prevent error messages (e.g., on systems where WMIC has been removed) from corrupting the for /f parsing output.

Conclusion

Retrieving the system manufacturer and model in Batch Script is a foundational capability for IT automation. By querying the Win32_ComputerSystem and Win32_BIOS WMI classes through the wmic command, administrators can programmatically identify hardware, route conditional driver installations, and populate inventory databases. Understanding the quirks of different OEM naming conventions, particularly Lenovo's cryptic internal model codes, ensures that scripts produce accurate, meaningful output across diverse hardware fleets.

Navigation