Skip to main content

How to List Installed Drivers in Batch Script

Understanding which drivers are installed on a system is a critical task for troubleshooting hardware issues, performing system inventories, or verifying that a specific piece of hardware has the correct software. Windows provides a powerful, built-in command-line utility called driverquery that is designed specifically to list all installed device drivers and their properties.

This guide will teach you how to use the driverquery command to get a detailed list of drivers, how to format the output for easy scripting, and how to capture this information to create a useful inventory report.

The Core Command: driverquery

The driverquery.exe utility is the standard command-line tool for displaying a list of installed device drivers. It can show basic information or a highly detailed (verbose) view, and it can format its output in different ways, making it perfect for both human inspection and automated scripting.

The basic syntax is: driverquery [switches]

Basic Example: A Simple Driver List

Running driverquery with no arguments gives a simple, table-formatted list of all drivers currently loaded on the system.

@ECHO OFF
ECHO --- Listing Installed Device Drivers ---
ECHO.
driverquery

The output is a table showing the module name, a display name, the type of driver, and the date it was linked.

--- Listing Installed Device Drivers ---

Module Name Display Name Driver Type Link Date
============ ====================== ============= ======================
1394ohci 1394 OHCI Compliant Ho Kernel 12/6/2019 10:24:43 PM
3ware 3ware Kernel 3/25/2019 4:54:33 PM
ACPI Microsoft ACPI Driver Kernel 12/6/2019 10:24:40 PM
AcpiDev ACPI B... Read Data Dr Kernel 4/11/2019 2:05:07 PM
... (and many more) ...

Key driverquery Parameters (/V, /FO)

To make the output more useful, you can use several command-line switches.

  • /FO <FORMAT>: Format Output. This is the most important switch for scripting. It controls the output format.
    • TABLE: The default, human-readable table.
    • LIST: A simple list of key-value pairs for each driver.
    • CSV: Comma-Separated Values. This is the best format for scripting, as it's easy to parse with a FOR /F loop.
  • /V: Verbose. This switch provides much more detailed information, including the driver's status (Running/Stopped), its disk path, memory usage, and more.
  • /SI: Provides Signing Information for the drivers.

How to Capture the Driver Information in a Script

To use the driver list in a script, you should format the output as CSV and then parse it with a FOR /F loop. This allows you to process each driver's properties individually.

This script lists the display name and type for each driver.

@ECHO OFF
SETLOCAL
ECHO --- Capturing Driver Information ---
ECHO.

REM 'skip=1' ignores the CSV header line.
REM 'tokens=1,2 delims=,' splits the CSV, grabbing the first two columns.
FOR /F "skip=1 tokens=1,2 delims=," %%A IN ('driverquery /FO CSV') DO (
ECHO Driver: %%~A, Type: %%~B
)

ENDLOCAL
note

%%~A is used to remove the quotes that CSV format puts around each field.

How this Method Works

The driverquery utility interfaces with the Windows operating system's kernel and Plug and Play manager. It queries the same system components that the graphical "Device Manager" uses to get its information. This makes it an authoritative source for the state of all loaded drivers, including kernel-level drivers, file system drivers, and standard hardware drivers.

Common Pitfalls and How to Solve Them

Problem: The Output is Hard to Parse in a Script

The default TABLE format is very difficult to parse reliably because the columns are separated by a variable number of spaces, and display names can contain spaces themselves.

Solution: Always use the /FO CSV switch when you intend for your script to process the output of driverquery. The comma is a reliable delimiter that makes parsing with FOR /F simple and robust.

Problem: Getting More Detailed Information

The default output is quite limited. For real diagnostics, you often need to know if a driver is running and where its file is located.

Solution: Use the /V (verbose) switch. When combined with /FO CSV, it adds many more columns to the output that you can then parse with the tokens option.

Practical Example: A Driver Inventory CSV Report

This script creates a comprehensive CSV report of all installed drivers, including their signing status, and saves it to the desktop. This is a perfect tool for system administrators.

@ECHO OFF
SETLOCAL
SET "REPORT_FILE=%USERPROFILE%\Desktop\Driver_Inventory.csv"

ECHO --- Driver Inventory Script ---
ECHO Creating driver report at: "%REPORT_FILE%"

REM Use driverquery with the /V (verbose), /SI (signing), and /FO CSV switches.
REM The output is redirected directly into our report file.
driverquery /V /SI /FO CSV > "%REPORT_FILE%"

IF %ERRORLEVEL% EQU 0 (
ECHO.
ECHO [SUCCESS] Report created successfully.
START "" "%REPORT_FILE%"
) ELSE (
ECHO.
ECHO [FAILURE] An error occurred while generating the report.
)

ENDLOCAL

This simple but powerful script leverages driverquery's own formatting capabilities to create a ready-to-use CSV file that can be opened in Excel or any spreadsheet program for analysis.

Conclusion

The driverquery command is the standard, built-in tool for listing and inspecting installed drivers from the command line. It provides a simple way to get a snapshot of the system's hardware and software configuration.

Key takeaways for using it in scripts:

  • Use driverquery for a basic list.
  • For scripting, always use the /FO CSV switch to produce clean, parsable output.
  • Add the /V switch for more detailed information like driver status and file path.
  • Use a FOR /F "skip=1 tokens=... delims=," loop to process the CSV output and use the data in your script.