Skip to main content

How to Get the System UUID in Batch Script

The Universally Unique Identifier (UUID) is a 128-bit number embedded in the system's BIOS or UEFI firmware by the manufacturer at the factory. Unlike the computer name (which users can change) or the MAC address (which changes if a network card is replaced), the UUID remains constant for the lifetime of the motherboard, making it one of the most reliable identifiers for hardware tracking, software licensing, and fleet management.

In this guide, we will explore how to retrieve the system UUID using Batch Script through WMI queries.

What is a System UUID?

A UUID follows the standard format of five groups of hexadecimal digits separated by hyphens: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Example: 4C4C4544-0044-3210-8035-B3C04F465331

This value is burned into the SMBIOS (System Management BIOS) tables during manufacturing. It is exposed by Windows through the Win32_ComputerSystemProduct WMI class and is accessible without Administrator privileges.

Method 1: Using WMIC

The most direct method to retrieve the UUID is through the wmic csproduct command.

@echo off
setlocal

echo Retrieving System UUID...

for /f "tokens=2 delims==" %%A in ('wmic csproduct get UUID /value ^| find "="') do (
for /f "delims=" %%B in ("%%A") do set "uuid=%%B"
)

if defined uuid (
echo System UUID: %uuid%
) else (
echo [ERROR] Could not retrieve UUID.
)

pause

Interpreting Special Values

Not all machines will return a valid UUID:

  • FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF: The manufacturer did not program a UUID. This is common on very cheap or custom-built machines.
  • 00000000-0000-0000-0000-000000000000: Same as above; the BIOS field was left at its default zero state.
  • A normal UUID like 4C4C4544-0044-3210-8035-B3C04F465331: A valid, unique identifier.

Method 2: Validating the UUID

Since some machines return placeholder UUIDs, a production script should check for these invalid patterns.

@echo off
setlocal

echo Checking System UUID...

for /f "tokens=2 delims==" %%A in ('wmic csproduct get UUID /value ^| find "="') do (
for /f "delims=" %%B in ("%%A") do set "uuid=%%B"
)

:: Check for invalid/placeholder UUIDs
set "valid=true"

if not defined uuid set "valid=false"
if /i "%uuid%" == "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF" set "valid=false"
if /i "%uuid%" == "00000000-0000-0000-0000-000000000000" set "valid=false"

if "%valid%" == "true" (
echo [VALID] System UUID: %uuid%
) else (
echo [INVALID] UUID is a placeholder or missing.
echo This machine does not have a manufacturer-assigned UUID.
echo Alternative: Use the MAC address or serial number for identification.
)

pause

Method 3: Comprehensive Machine Fingerprint

For licensing systems or inventory databases, the UUID is often combined with other hardware identifiers to create a composite "machine fingerprint" that is extremely difficult to spoof.

@echo off
setlocal enabledelayedexpansion

echo =============================================
echo MACHINE FINGERPRINT
echo =============================================
echo.

:: 1. System UUID
for /f "tokens=2 delims==" %%A in ('wmic csproduct get UUID /value ^| find "="') do (
for /f "delims=" %%B in ("%%A") do set "uuid=%%B"
)
echo UUID: !uuid!

:: 2. Serial Number
for /f "tokens=2 delims==" %%A in ('wmic bios get SerialNumber /value ^| find "="') do (
for /f "delims=" %%B in ("%%A") do set "serial=%%B"
)
echo Serial: !serial!

:: 3. Motherboard Serial
for /f "tokens=2 delims==" %%A in ('wmic baseboard get SerialNumber /value ^| find "="') do (
for /f "delims=" %%B in ("%%A") do set "mb_serial=%%B"
)
echo MB Serial: !mb_serial!

:: 4. Primary MAC Address
set "mac="
for /f "tokens=2 delims==" %%A in ('wmic nic where "NetConnectionStatus=2" get MACAddress /value ^| find "="') do (
if not defined mac (
for /f "delims=" %%B in ("%%A") do set "mac=%%B"
)
)
echo MAC Address: !mac!

:: 5. CPU ID
for /f "tokens=2 delims==" %%A in ('wmic cpu get ProcessorId /value ^| find "="') do (
for /f "delims=" %%B in ("%%A") do set "cpuid=%%B"
)
echo Processor ID: !cpuid!

:: 6. Computer Name
echo Computer Name: %COMPUTERNAME%

echo.
echo =============================================

:: Create a composite key (for demonstration)
echo.
echo Composite Key: !uuid!-!serial!-!mac!

pause

Why Multiple Identifiers?

No single identifier is perfect:

  • UUID: Can be a placeholder on cheap hardware.
  • Serial Number: Can read "To Be Filled By O.E.M.".
  • MAC Address: Changes if the NIC is replaced.
  • Processor ID: Identical across the same CPU model.

By combining multiple values, you create a composite key that is highly unique and resistant to hardware swaps.

Method 4: PowerShell Alternative

For environments moving away from wmic:

@echo off
setlocal

echo Getting UUID via PowerShell...

for /f "delims=" %%A in ('powershell -noprofile -command ^
"(Get-CimInstance Win32_ComputerSystemProduct).UUID"') do set "uuid=%%A"

echo System UUID: %uuid%
pause

Practical Use Case: License Key Binding

Software vendors often bind license keys to the system UUID to prevent unauthorized copying. Here is a simplified script that checks if the current machine's UUID matches the licensed hardware.

@echo off
setlocal enabledelayedexpansion

:: The UUID this license was issued for
set "licensed_uuid=4C4C4544-0044-3210-8035-B3C04F465331"

:: Get current machine's UUID without trailing carriage return
for /f "tokens=2 delims==" %%A in ('wmic csproduct get UUID /value ^| find "="') do (
set "raw_uuid=%%A"
:: Remove any remaining carriage return by re-parsing
for /f "delims=" %%B in ("!raw_uuid!") do set "current_uuid=%%B"
)

echo Licensed UUID: %licensed_uuid%
echo Current UUID: %current_uuid%

if /i "%current_uuid%" == "%licensed_uuid%" (
echo [AUTHORIZED] This machine matches the license.
echo Launching application...
rem start "" "C:\Program Files\MyApp\app.exe"
) else (
echo [DENIED] This machine is not authorized.
echo Contact support for a new license key.
)

pause
endlocal

Common Mistakes

The Wrong Way: Assuming the UUID is Always Unique

:: WRONG - Does not handle placeholder UUIDs
for /f "tokens=2 delims==" %%A in ('wmic csproduct get UUID /value ^| find "="') do set "uuid=%%A"
:: Directly using %uuid% as a database primary key

Output Concern: If two machines in your fleet both report FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF, your inventory database will have a primary key collision. Always validate the UUID before using it as a unique identifier.

The Wrong Way: Confusing UUID with GUID

While the terms UUID and GUID are technically synonymous (both are 128-bit identifiers), the system UUID from the BIOS is not the same as the various GUIDs used by Windows for power plans, disk partitions, or software components. The system UUID is a hardware-level identifier, fixed at the factory.

Best Practices

  1. Always validate: Check for all-F and all-zero placeholder UUIDs before trusting the value for identification purposes.
  2. Combine with other identifiers: Use the UUID as part of a composite fingerprint alongside serial numbers and MAC addresses for robust machine identification.
  3. Use case-insensitive comparison: UUIDs may be returned in mixed case depending on the BIOS vendor. Always use /i in if comparisons.
  4. Transition to PowerShell: As wmic approaches deprecation, use Get-CimInstance Win32_ComputerSystemProduct for future-proof scripts.

Conclusion

Retrieving the system UUID in Batch Script is a single WMI query against the Win32_ComputerSystemProduct class. As a hardware-burned identifier that persists across OS reinstallations and user changes, the UUID serves as one of the most stable anchors for inventory management and license binding. By validating for placeholder values and combining the UUID with complementary identifiers like serial numbers and MAC addresses, administrators can build reliable, spoof-resistant machine identification systems.