How to Get Monitor Details in Batch Script
For system inventory, remote support, or diagnostic scripts, you often need to identify the physical displays connected to a computer. Knowing the monitor's model, manufacturer, and current resolution can be crucial for troubleshooting display issues or cataloging hardware assets. This information is available 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 details about all connected desktop monitors. You will learn how to capture this information into variables and create a simple report of the system's display configuration.
The Core Command: WMIC PATH Win32_DesktopMonitor
The standard way to get hardware information is with WMIC. To get monitor details, we must query the Win32_DesktopMonitor WMI class directly.
Syntax: WMIC PATH Win32_DesktopMonitor GET <Property1,Property2,...>
WMIC PATH Win32_DesktopMonitor: Specifies the WMI class we are querying.GET ...: The specific properties we want to retrieve.
Key Monitor Properties Explained
Name: The user-friendly name of the monitor (e.g., "Generic PnP Monitor").Description: A more detailed description, often the same asName.ScreenWidth: The width of the monitor's current resolution in pixels (e.g.,1920).ScreenHeight: The height of the monitor's current resolution in pixels (e.g.,1080).MonitorManufacturer: The name of the manufacturer (e.g., "Dell Inc."). This is often more accurate than theName.
Basic Example: Displaying All Monitor Details
You can run this command directly in a command prompt to see the details for all connected monitors.
@ECHO OFF
ECHO --- Querying Monitor Details ---
ECHO.
WMIC PATH Win32_DesktopMonitor GET Name, MonitorManufacturer, ScreenWidth, ScreenHeight
The output on a system with two monitors from WMIC is a table listing each detected monitor.
--- Querying Monitor Details ---
MonitorManufacturer Name ScreenHeight ScreenWidth
Dell Inc. DELL U2718Q 2160 3840
(Standard monitor types) Generic PnP Monitor 1080 1920
How to Capture the Information in a Script
To use this data, you should have WMIC format the output as CSV and then parse it with a FOR /F loop. This is the most reliable way to handle manufacturer and model names that contain spaces.
Script
@ECHO OFF
SETLOCAL
ECHO --- Capturing a List of All Monitors ---
ECHO.
REM 'skip=1' ignores the header. 'tokens=2-5' grabs the four data columns.
FOR /F "skip=1 tokens=2,3,4,5 delims=," %%A IN (
'WMIC PATH Win32_DesktopMonitor GET Name,MonitorManufacturer,ScreenWidth,ScreenHeight /FORMAT:CSV'
) DO (
ECHO Found Monitor:
ECHO Manufacturer: "%%~B"
ECHO Name: "%%~A"
ECHO Resolution: %%~C x %%~D
ECHO.
)
ENDLOCAL
The ~ modifier (%%~A) is used to remove the quotes that the CSV format adds.
How the WMIC Method Works
The WMIC command interfaces with the WMI service, which gets its information from the operating system's hardware layer. For monitors, this data is typically read from the EDID (Extended Display Identification Data) that is stored in the monitor's own firmware. The monitor communicates this information to the graphics card and driver when it is connected, and WMI makes this data available for us to query.