Skip to main content

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 as Name.
  • 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 the Name.

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
note

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.

Common Pitfalls and How to Solve Them

Problem: The System Has Multiple Monitors

As shown in the examples, the WMIC command will list all connected monitors. The FOR /F loop will correctly iterate through each one, allowing you to process or report on all of them. This is the desired behavior for an inventory script.

Problem: The Manufacturer or Model is Generic

Sometimes, especially with older monitors or certain adapters, the Name and MonitorManufacturer fields will return a generic value like "Generic PnP Monitor" instead of the specific model name.

Solution: This is a limitation of the information provided by the monitor's driver or the EDID data itself, not a failure of the script. In these cases, the information is simply not available to WMI.

Problem: The Serial Number is Not Available

You may notice that the Win32_DesktopMonitor class does not have a SerialNumber property. Retrieving a monitor's serial number is a much more complex task that is not reliably possible with a simple WMIC command. It often requires parsing raw EDID data, which is best handled by a more advanced PowerShell script or a third-party tool.

Solution: For batch scripting, you should rely on the Model (Name) and MonitorManufacturer for identification and accept that the serial number is not easily accessible.

Practical Example: A Full Display Inventory Report

This script creates a detailed report of all connected monitors and saves it to a text file.

@ECHO OFF
SETLOCAL
SET "ReportFile=%USERPROFILE%\Desktop\Display_Inventory.txt"

ECHO --- Display Inventory Script ---
ECHO Creating report at: "%ReportFile%"

(
ECHO Display Inventory for: %COMPUTERNAME%
ECHO Generated on: %DATE% at %TIME%
ECHO ------------------------------------
) > "%ReportFile%"

REM Use the /FORMAT:LIST option for a clear, readable report format.
(
ECHO.
WMIC PATH Win32_DesktopMonitor GET * /FORMAT:LIST
) >> "%ReportFile%"

ECHO.
ECHO [SUCCESS] Report created.
START "" "%ReportFile%"
ENDLOCAL
note

GET * /FORMAT:LIST is a great trick to get all available properties for an object in a clean, key-value list format.

Conclusion

The WMIC PATH Win32_DesktopMonitor command is the standard, built-in method for retrieving information about connected displays from a batch script.

Key takeaways:

  • Use WMIC PATH Win32_DesktopMonitor GET Name,MonitorManufacturer,ScreenWidth,ScreenHeight to query the key details.
  • For scripting, always use a machine-readable format like /FORMAT:CSV and parse it with a FOR /F loop.
  • The command will list all connected monitors.
  • Be aware that a monitor's serial number is not available through this simple WMI class.