How to Get the BIOS Version and Date in Batch Script
Retrieving detailed hardware information is a common requirement for diagnostic, inventory, and pre-flight check scripts. The BIOS (or UEFI) version and its release date are crucial for determining if a system needs a firmware update, for verifying a standard hardware configuration, or for general asset management. This low-level information is not stored in a simple file but is accessible through the Windows Management Instrumentation (WMI) framework.
This guide will teach you how to use the built-in WMIC (Windows Management Instrumentation Command-line) utility to query the system for its BIOS version and release date directly from a batch script. You will learn how to capture these specific values into variables for use in your reports and scripts.
The Core Command: WMIC BIOS GET
The standard tool for querying hardware from the command line is WMIC. The BIOS alias provides a direct interface to the Win32_BIOS WMI class, which contains the firmware information.
Syntax: WMIC BIOS GET SMBIOSBIOSVersion, ReleaseDate
WMIC: The command-line utility.BIOS: The alias for the motherboard's BIOS/UEFI firmware.GET ...: The specific properties we want to retrieve.
Key BIOS Properties Explained
SMBIOSBIOSVersion: This property holds the full version string of the BIOS, as reported by the manufacturer (e.g.,F.31,1.12.0). This is often the most useful value.ReleaseDate: This property provides the date the BIOS version was released. The format is a standardized WMI timestamp:YYYYMMDDHHMMSS.fractionalseconds.
Basic Example: Displaying the BIOS Information
You can run this command directly in a command prompt to see the BIOS details for the current machine.
@ECHO OFF
ECHO --- Querying BIOS Version and Release Date ---
ECHO.
WMIC BIOS GET SMBIOSBIOSVersion, ReleaseDate
The output from WMIC is formatted in columns with a header.
--- Querying BIOS Version and Release Date ---
ReleaseDate SMBIOSBIOSVersion
20220510000000.000000+000 F.31
How to Capture the Information in Variables
To use this data in a script, you need to parse the WMIC output. A FOR /F loop is the standard tool for this, allowing you to capture the version and date into separate variables.
@ECHO OFF
SET "BIOS_Version="
SET "BIOS_Date="
ECHO --- Capturing BIOS Information ---
REM 'skip=1' ignores the header. 'tokens=1,2' grabs the two columns.
FOR /F "skip=1 tokens=1,2" %%A IN (
'WMIC BIOS GET ReleaseDate, SMBIOSBIOSVersion'
) DO (
SET "BIOS_Date=%%A"
SET "BIOS_Version=%%B"
GOTO :InfoCaptured
)
:InfoCaptured
IF NOT DEFINED BIOS_Version (
ECHO [FAILURE] Could not retrieve BIOS information.
GOTO :EOF
)
ECHO.
ECHO BIOS Version: %BIOS_Version%
ECHO Release Date (Raw): %BIOS_Date%
skip=1: Ignores theReleaseDate SMBIOSBIOSVersionheader line.tokens=1,2: Assigns the first column (the date) to%%Aand the second column (the version) to%%B.GOTO :InfoCaptured: Exits the loop immediately after capturing the first line of data to prevent the variables from being overwritten by blank lines.
How the WMIC BIOS Command Works
The WMIC BIOS command queries the Win32_BIOS WMI class. This information is read directly from the System Management BIOS (SMBIOS) data tables, which are populated by the motherboard's firmware when the computer boots up. This makes WMIC an authoritative source for hardware-level details, as it's getting the information directly from the hardware's own reporting mechanism.
Common Pitfalls and How to Solve Them
Problem: The Values are Generic or Missing
On some computers, especially custom-built or "white-box" machines, the manufacturer may not have correctly filled in all the SMBIOS fields. You might get a blank value or a generic placeholder.
Solution: This is a limitation of the hardware's firmware, not a script failure. Your script can handle this by checking if the captured variable is defined (IF DEFINED BIOS_Version).
Problem: Parsing the WMIC Output
The default table format of WMIC can be tricky to parse. The FOR /F "skip=1" loop with a GOTO is the most reliable pattern for capturing its output and avoiding issues with extra blank lines.
Practical Example: A Detailed System Hardware Report
This script combines several WMIC queries to create a comprehensive hardware profile of a machine, including the BIOS details.
@ECHO OFF
SETLOCAL
SET "ReportFile=%USERPROFILE%\Desktop\Hardware_Report.txt"
ECHO --- Generating System Hardware Report ---
ECHO Saving report to: "%ReportFile%"
(
ECHO Hardware Report for: %COMPUTERNAME%
ECHO Generated on: %DATE% at %TIME%
ECHO ------------------------------------
ECHO.
REM --- Get Motherboard Info ---
FOR /F "skip=1 tokens=1,*" %%A IN ('WMIC BASEBOARD GET Manufacturer, Product') DO (
SET "MoboMan=%%A" & SET "MoboMod=%%B" & GOTO :GotMobo
)
:GotMobo
ECHO Motherboard: %MoboMan% - %MoboMod%
REM --- Get BIOS Info ---
FOR /F "skip=1 tokens=1,2" %%A IN ('WMIC BIOS GET ReleaseDate, SMBIOSBIOSVersion') DO (
SET "BIOS_Date=%%A" & SET "BIOS_Version=%%B" & GOTO :GotBIOS
)
:GotBIOS
ECHO BIOS Version: %BIOS_Version% (Released: %BIOS_Date:~0,8%)
REM --- Get CPU Info ---
FOR /F "skip=1 delims=" %%C IN ('WMIC CPU GET Name') DO (
SET "CPUName=%%C" & GOTO :GotCPU
)
:GotCPU
ECHO Processor: %CPUName%
) > "%ReportFile%"
ECHO.
ECHO --- Report Complete ---
START "" "%ReportFile%"
ENDLOCAL
%BIOS_Date:~0,8% is a substring trick to show just the YYYYMMDD part of the raw timestamp.
Conclusion
The WMIC BIOS command is the standard, built-in, and most reliable method for getting a computer's firmware version and release date from a batch script.
Key takeaways:
- Use
WMIC BIOS GET SMBIOSBIOSVersion, ReleaseDateto query the BIOS information. - Use a
FOR /F "skip=1 tokens=..."loop with aGOTOto reliably capture the data into variables. - Be aware that some hardware manufacturers may not provide complete or accurate information.
- This command can be extended to query remote machines (
/NODE:"hostname") for powerful network-wide inventory.