How to Check if Windows is Running in UEFI or Legacy BIOS Mode in Batch Script
Understanding whether your operating system is booting via UEFI (Unified Extensible Firmware Interface) or the older "Legacy BIOS" (Basic Input/Output System) is critical for system maintenance. UEFI is the modern standard that supports larger hard drives (GPT partition style), faster boot times, and advanced security features like "Secure Boot." For IT administrators and builders, identifying this mode is an essential first step before attempting to install Windows 11, manage disk partitions, or configure hardware-level security.
This guide explains how to detect your boot mode using a Batch script.
Why Check for UEFI vs. Legacy BIOS?
- OS Upgrade Planning: Windows 11 strictly requires UEFI mode; knowing your boot state tells you if you need to convert your drive before upgrading.
- Disk Partitioning: UEFI requires GPT (GUID Partition Table) disks, while Legacy BIOS uses MBR (Master Boot Record). Using the wrong commands can lead to data loss.
- Security Auditing: Features like "Credential Guard" and "Secure Boot" can only run on UEFI-based systems.
Windows 8 and newer versions store the boot mode in a specific registry value that identifies exactly how the kernel was loaded.
Method 1: Using the Registry (Most Efficient)
The most direct way to check the boot mode from a Batch script is to query the FirmwareType value.
@echo off
setlocal
set "REG_PATH=HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control"
echo [PROCESS] Detecting Boot Firmware Type...
set "F_TYPE="
for /f "tokens=3" %%a in ('reg query "%REG_PATH%" /v FirmwareType 2^>nul ^| findstr /i "FirmwareType"') do set "F_TYPE=%%a"
if "%F_TYPE%"=="0x1" (
echo [STATUS] This machine is running in LEGACY BIOS mode.
) else if "%F_TYPE%"=="0x2" (
echo [STATUS] This machine is running in UEFI mode.
) else (
echo [INFO] Could not determine firmware type from registry.
echo [NOTE] The FirmwareType key requires Windows 8 or later.
echo [HELP] Use Method 2 (BCDedit^) for older systems.
)
pause
Method 2: Using BCDedit (The Reliable Alternative)
The Boot Configuration Data (BCD) stores the path to the boot loader. If the path contains .efi, it's UEFI. If it contains .exe, it's Legacy.
@echo off
setlocal
:: BCDedit requires admin rights
net session >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Administrator privileges are required for BCDedit.
pause
exit /b 1
)
echo [PROCESS] Checking Boot Loader Path...
bcdedit /enum {current} 2>nul | findstr /i /c:"winload.efi" >nul
if %errorlevel% equ 0 (
echo [STATUS] UEFI detected (EFI boot loader^).
pause
exit /b 0
)
bcdedit /enum {current} 2>nul | findstr /i /c:"winload.exe" >nul
if %errorlevel% equ 0 (
echo [STATUS] Legacy BIOS detected (legacy boot loader^).
pause
exit /b 0
)
echo [ERROR] Could not determine boot mode from BCD data.
pause
Creating a System Readiness Auditor
A professional script checks the boot mode using both methods and provides clear advice for modern Windows compatibility.
@echo off
setlocal
echo ============================================================
echo Boot Infrastructure Readiness Auditor
echo ============================================================
:: 0. Check for admin rights (needed for BCDedit verification)
net session >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Administrator privileges are required.
pause
exit /b 1
)
:: 1. Check Registry
echo.
echo [CHECK 1] Registry Firmware Type:
set "FW_TYPE="
for /f "tokens=3" %%a in ('reg query "HKLM\System\CurrentControlSet\Control" /v FirmwareType 2^>nul ^| findstr /i "FirmwareType"') do set "FW_TYPE=%%a"
if "%FW_TYPE%"=="0x2" (
echo [PASS] Boot Mode: UEFI
) else if "%FW_TYPE%"=="0x1" (
echo [INFO] Boot Mode: Legacy BIOS
) else (
echo [INFO] FirmwareType key not found (pre-Windows 8?^).
)
:: 2. Cross-Verify with BCD
echo.
echo [CHECK 2] Boot Loader Verification:
set "BCD_MODE=UNKNOWN"
bcdedit /enum {current} 2>nul | findstr /i /c:"winload.efi" >nul
if %errorlevel% equ 0 (
set "BCD_MODE=UEFI"
echo [PASS] EFI boot loader detected.
) else (
bcdedit /enum {current} 2>nul | findstr /i /c:"winload.exe" >nul
if %errorlevel% equ 0 (
set "BCD_MODE=LEGACY"
echo [INFO] Legacy boot loader detected.
) else (
echo [WARN] Could not determine boot loader type.
)
)
:: 3. Summary
echo.
echo ============================================================
if "%FW_TYPE%"=="0x2" (
echo OVERALL: System is UEFI-based.
echo [INFO] Supports GPT disks, Secure Boot, and Windows 11.
) else if "%FW_TYPE%"=="0x1" (
echo OVERALL: System is Legacy BIOS-based.
echo [WARN] May need conversion to UEFI for Windows 11.
echo [HELP] Use 'mbr2gpt.exe /validate' to check conversion readiness.
) else if "%BCD_MODE%"=="UEFI" (
echo OVERALL: System is UEFI-based (confirmed via BCD^).
) else if "%BCD_MODE%"=="LEGACY" (
echo OVERALL: System is Legacy BIOS-based (confirmed via BCD^).
) else (
echo OVERALL: Boot mode could not be determined.
)
echo ============================================================
pause
Common Pitfalls and How to Avoid Them
Administrative Rights
The bcdedit command and some restricted parts of the CurrentControlSet registry require Administrator privileges. If you run your script as a standard user, you might get an "Access Denied" error or an empty result.
Windows 7 Compatibility
Note that the FirmwareType registry key was only introduced in Windows 8.
If you are auditing a Windows 7 machine, use Method 2 (BCDedit). It is the most consistent way to check the boot mode across all NT-based operating systems from the last decade.
Best Practices for Boot Management
- Check Partition Style: Alongside UEFI detection, use
diskpartorpowershell -NoProfile -Command "Get-Disk"to verify if the drive is GPT. A UEFI system cannot boot from an MBR drive. - CSM Mode Warning: Some computers support both. If your script shows "Legacy" but the hardware is new, the user might have "Compatibility Support Module" (CSM) enabled in their BIOS.
- Audit Version Drift: In a mixed environment of old and new PCs, use your script to log boot modes to a central file to identify which machines are ready for the next security update.
Never attempt to switch from Legacy to UEFI in the BIOS without first converting your disk from MBR to GPT (using a tool like mbr2gpt.exe), or the computer will fail to boot into Windows.
Conclusion
Detecting whether Windows is running in UEFI or Legacy BIOS mode via Batch script is a fundamental prerequisite for modern system administration. By accurately identifying your boot infrastructure, you can prevent installation errors, plan for OS upgrades, and ensure that your security hardware is utilized to its full potential. This professional approach to system identification maintains the operational integrity of your organization, providing a clear, automated view of your hardware configuration and ensuring your infrastructure remains compatible with the future of the Windows platform.