Skip to content

How to Get the Windows SKU Identifier in Batch Script

Learn how to retrieve the numeric Windows SKU ID in Batch scripts using WMIC, registry queries, and PowerShell for license audits, deployment scripts, and system inventory reporting.

Every Windows installation has a SKU (Stock Keeping Unit) identifier that describes the exact edition of the operating system installed. While most users think of "Windows 10 Pro" or "Windows 11 Home," the SKU identifier is a numeric code that provides precise differentiation between editions, including distinctions that the marketing name alone does not convey (such as single-language editions, N editions without media features, or volume-licensed variants). Retrieving the SKU from a Batch Script is essential for license audits, conditional logic in deployment scripts, and system inventory reporting.

In this guide, we will explore how to retrieve the Windows SKU identifier from a Batch Script using wmic, slmgr, the registry, and PowerShell.

Understanding Windows SKU IDs

Each Windows edition has a unique numeric SKU. Here are some common ones:

SKU ID Edition
4 Windows Enterprise
6 Windows Business
27 Windows Enterprise N
48 Windows Professional
49 Windows Home Basic
98 Windows Home Single Language
100 Windows Server Standard (Core)
101 Windows Home
121 Windows Education
125 Windows Enterprise LTSB/LTSC
161 Windows Pro for Workstations
162 Windows Pro for Workstations N
175 Windows Server Standard

Method 1: Using WMIC

The wmic os command exposes the OperatingSystemSKU property:

@echo off
setlocal

echo =============================================
echo   WINDOWS SKU IDENTIFIER
echo =============================================
echo.

for /f "tokens=2 delims==" %%a in ('wmic os get OperatingSystemSKU /value 2^>nul ^| find "="') do (
    for /f "delims=" %%b in ("%%a") do set "SKU=%%b"
)

if defined SKU (
    echo SKU ID: %SKU%
    call :decode %SKU%
) else (
    echo [ERROR] Could not retrieve SKU.
)

pause
exit /b

:decode
if "%1"=="4"   echo Edition: Enterprise
if "%1"=="6"   echo Edition: Business
if "%1"=="27"  echo Edition: Enterprise N
if "%1"=="48"  echo Edition: Professional
if "%1"=="49"  echo Edition: Home Basic
if "%1"=="98"  echo Edition: Home Single Language
if "%1"=="100" echo Edition: Server Standard (Core^)
if "%1"=="101" echo Edition: Home
if "%1"=="121" echo Edition: Education
if "%1"=="125" echo Edition: Enterprise LTSC
if "%1"=="161" echo Edition: Pro for Workstations
if "%1"=="175" echo Edition: Server Standard
exit /b

Example output:

=============================================
  WINDOWS SKU IDENTIFIER
=============================================

SKU ID: 48
Edition: Professional

Method 2: Using the Registry

The SKU information is stored in the registry alongside other OS identification data:

@echo off
setlocal

set "KEY=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion"

echo Querying registry for SKU data...
echo.

:: Edition ID (e.g., "Professional", "Enterprise")
for /f "tokens=2,*" %%a in ('reg query "%KEY%" /v EditionID 2^>nul ^| findstr /i "EditionID"') do set "EDITION=%%b"

:: Product Name (e.g., "Windows 10 Pro")
for /f "tokens=2,*" %%a in ('reg query "%KEY%" /v ProductName 2^>nul ^| findstr /i "ProductName"') do set "PRODUCT=%%b"

:: Composition Edition ID (e.g., "Enterprise" on volume license)
for /f "tokens=2,*" %%a in ('reg query "%KEY%" /v CompositionEditionID 2^>nul ^| findstr /i "CompositionEditionID"') do set "COMP_EDITION=%%b"

:: Installation Type (e.g., "Client", "Server")
for /f "tokens=2,*" %%a in ('reg query "%KEY%" /v InstallationType 2^>nul ^| findstr /i "InstallationType"') do set "INSTALL_TYPE=%%b"

echo Product Name:      %PRODUCT%
echo Edition ID:        %EDITION%
echo Composition:       %COMP_EDITION%
echo Installation Type: %INSTALL_TYPE%

pause

Method 3: Combined SKU Report

Gather SKU information from multiple sources for a comprehensive report:

@echo off
setlocal EnableDelayedExpansion

set "KEY=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion"

echo =============================================
echo   WINDOWS EDITION REPORT
echo   %COMPUTERNAME% - %date%
echo =============================================
echo.

:: OS SKU (numeric)
for /f "tokens=2 delims==" %%a in ('wmic os get OperatingSystemSKU /value 2^>nul ^| find "="') do (
    for /f "delims=" %%b in ("%%a") do set "SKU=%%b"
)

:: OS Caption (full name)
for /f "tokens=2 delims==" %%a in ('wmic os get Caption /value 2^>nul ^| find "="') do (
    for /f "delims=" %%b in ("%%a") do set "CAPTION=%%b"
)

:: OS Architecture
for /f "tokens=2 delims==" %%a in ('wmic os get OSArchitecture /value 2^>nul ^| find "="') do (
    for /f "delims=" %%b in ("%%a") do set "ARCH=%%b"
)

:: Build number
for /f "tokens=2 delims==" %%a in ('wmic os get BuildNumber /value 2^>nul ^| find "="') do (
    for /f "delims=" %%b in ("%%a") do set "BUILD=%%b"
)

:: Registry values
for /f "tokens=2,*" %%a in ('reg query "%KEY%" /v EditionID 2^>nul ^| findstr /i "EditionID"') do set "EDITION=%%b"
for /f "tokens=2,*" %%a in ('reg query "%KEY%" /v DisplayVersion 2^>nul ^| findstr /i "DisplayVersion"') do set "VERSION=%%b"
for /f "tokens=2,*" %%a in ('reg query "%KEY%" /v InstallationType 2^>nul ^| findstr /i "InstallationType"') do set "TYPE=%%b"

echo   Caption:      !CAPTION!
echo   Edition:      !EDITION!
echo   SKU ID:       !SKU!
echo   Version:      !VERSION!
echo   Build:        !BUILD!
echo   Arch:         !ARCH!
echo   Install Type: !TYPE!

pause

Method 4: SKU-Based Conditional Logic

Use the SKU to run different logic depending on the Windows edition:

@echo off
setlocal

:: Get SKU
for /f "tokens=2 delims==" %%a in ('wmic os get OperatingSystemSKU /value 2^>nul ^| find "="') do (
    for /f "delims=" %%b in ("%%a") do set "SKU=%%b"
)

:: Enterprise and Education editions (supports Group Policy, BitLocker, etc.)
if "%SKU%"=="4"   goto :enterprise
if "%SKU%"=="27"  goto :enterprise
if "%SKU%"=="121" goto :enterprise
if "%SKU%"=="125" goto :enterprise

:: Professional editions
if "%SKU%"=="48"  goto :professional
if "%SKU%"=="161" goto :professional

:: Home editions
if "%SKU%"=="101" goto :home
if "%SKU%"=="98"  goto :home

:: Server editions
if "%SKU%"=="100" goto :server
if "%SKU%"=="175" goto :server

echo [INFO] Unknown SKU: %SKU%. Using default configuration.
goto :continue

:enterprise
echo [SKU] Enterprise/Education edition detected.
echo Applying enterprise group policies...
goto :continue

:professional
echo [SKU] Professional edition detected.
echo Applying standard business configuration...
goto :continue

:home
echo [SKU] Home edition detected.
echo [WARNING] Some features (Group Policy, BitLocker^) are not available.
echo Applying limited configuration...
goto :continue

:server
echo [SKU] Server edition detected.
echo Applying server-specific configuration...
goto :continue

:continue
echo.
echo Configuration applied for SKU %SKU%.
pause

Method 5: PowerShell-Enhanced SKU Lookup

For a precise mapping without hardcoding every SKU:

@echo off

echo Retrieving detailed SKU information...
echo.

powershell -NoProfile -Command ^
  "$os = Get-CimInstance Win32_OperatingSystem;" ^
  "$sku = $os.OperatingSystemSKU;" ^
  "Write-Host ('Product:  ' + $os.Caption);" ^
  "Write-Host ('SKU ID:   ' + $sku);" ^
  "Write-Host ('Edition:  ' + (Get-WindowsEdition -Online).Edition);" ^
  "Write-Host ('Version:  ' + $os.Version);" ^
  "Write-Host ('Build:    ' + $os.BuildNumber);" ^
  "Write-Host ('Arch:     ' + $os.OSArchitecture)"

pause

Remote SKU Query

Check the SKU on a remote machine:

@echo off
setlocal

set /p "COMPUTER=Remote computer name: "

echo Querying SKU from %COMPUTER%...

for /f "tokens=2 delims==" %%a in ('wmic /node:"%COMPUTER%" os get OperatingSystemSKU /value 2^>nul ^| find "="') do (
    for /f "delims=" %%b in ("%%a") do set "SKU=%%b"
)
for /f "tokens=2 delims==" %%a in ('wmic /node:"%COMPUTER%" os get Caption /value 2^>nul ^| find "="') do (
    for /f "delims=" %%b in ("%%a") do set "NAME=%%b"
)

if defined SKU (
    echo Machine:  %COMPUTER%
    echo Edition:  %NAME%
    echo SKU ID:   %SKU%
) else (
    echo [ERROR] Could not connect to %COMPUTER%.
)

pause

Common Mistakes

The Wrong Way: Using the Product Name for Logic

:: WRONG - Product name varies by language and version
for /f "tokens=2 delims==" %%a in ('wmic os get Caption /value') do set "OS=%%a"
echo %OS% | findstr /i "Pro" >nul && echo This is Pro
:: Breaks on non-English Windows: "Windows 10 Professionnel"

Output Concern: The product name (Caption) is localized and changes with language packs. The numeric SKU ID is the same on every language version of Windows, making it the reliable choice for conditional logic.

The Wrong Way: Confusing Edition ID with SKU

:: MISLEADING - EditionID is a string, not the numeric SKU
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID
:: Returns "Professional" not "48"

EditionID is a human-readable string, while OperatingSystemSKU is the numeric identifier. Use the right one depending on whether you need display text or programmatic logic.

Best Practices

  1. Use numeric SKU for logic: It is language-independent and unique per edition.
  2. Use EditionID for display: Show human-readable edition names in reports.
  3. Group SKUs by capability: Map SKUs to feature tiers (Home, Pro, Enterprise) for cleaner branching.
  4. Cache the result: Query the SKU once and store it in a variable rather than calling wmic repeatedly.
  5. Include SKU in inventory reports: The numeric SKU enables precise license tracking.

Conclusion

Retrieving the Windows SKU identifier from a Batch Script is done most reliably with wmic os get OperatingSystemSKU, which returns the numeric edition code that is consistent across all Windows languages. By combining the numeric SKU with human-readable registry values like EditionID and ProductName, scripts can both display edition information to users and make precise conditional decisions based on the installed Windows edition. This is essential for deployment scripts that must adapt their behavior based on whether the target machine runs Home, Professional, Enterprise, or Server editions.

Navigation