Hi t3chgr0g
@echo off
REM Set the display mode to duplicate on monitors 1 and 2
echo Selecting duplicate display mode...
DisplaySwitch.exe /clone
REM Optional: Add a pause to view the result
pause
- Save the file with a
.bat
extension (e.g.,duplicate_displays.bat
). - Double-click the batch file to execute it.
When you run the batch file, it will set the display mode to duplicate, effectively mirroring the content on monitors 1 and 2. The DisplaySwitch.exe /clone
command is used to accomplish this. If you want to view the result before the batch file exits, you can uncomment the pause
command by removing the REM
at the beginning of the line.
Note that the DisplaySwitch.exe
utility is a built-in command-line tool in Windows that allows you to control the display settings. By using it with the /clone
switch, you can duplicate the display on multiple monitors.
Remember to adjust the batch file and display settings accordingly if you have more than two monitors or if your monitor numbering differs from the default configuration.
another answer by using PowerShell:
import the Win32_Monitor WMI class
import-module win32
Get the list of all monitors
$monitors = get-wmiobject win32_monitor
Get the names of monitors 1 and 2
$monitor1 = $monitors[0].name $monitor2 = $monitors[1].name
Duplicate the display on monitors 1 and 2
(Get-WmiObject Win32_VideoController).SetDisplayConfig([Microsoft.Win32.SystemParametersInfo]::EnumDisplaySettings.Extend, $monitor1, $monitor2)
This script will first import the Win32_Monitor WMI class. This class provides information about all monitors on the system. The script will then get the list of all monitors and get the names of monitors 1 and 2. Finally, the script will duplicate the display on monitors 1 and 2 by calling the SetDisplayConfig method on the Win32_VideoController WMI class.
Here is a more detailed explanation of the script:
-
import-module win32
imports the Win32_Monitor WMI class. -
get-wmiobject win32_monitor
gets the list of all monitors. -
$monitors[0].name
gets the name of monitor 1. -
$monitors[1].name
gets the name of monitor 2. -
(Get-WmiObject Win32_VideoController).SetDisplayConfig([Microsoft.Win32.SystemParametersInfo]::EnumDisplaySettings.Extend, $monitor1, $monitor2)
calls the SetDisplayConfig method on the Win32_VideoController WMI class to duplicate the display on monitors 1 and 2.