Disable/Enable 2nd/3rd monitor programmatically. (Win10) [duplicate]

Solution 1:

How can I disable a monitor programmatically?

You can use the MultiMonitorTool by Nirsoft:

MultiMonitorTool is a small tool that allows you to do some actions related to working with multiple monitors. With MultiMonitorTool, you can disable/enable monitors, set the primary monitor, save and load the configuration of all monitors, and move windows from one monitor to another. You can do these actions from the user interface or from command-line, without displaying user interface. MultiMonitorTool also provides a preview window, which allows you to watch a preview of every monitor on your system.

System Requirements and Limitations

  • This utility works on any version of Windows, starting from Windows XP and up to Windows 10. Both 32-bit and x64 systems are supported.
  • This utility is only useful if your desktop is extended to multiple monitors. If you have multiple monitors that display the same content, then is useless for you.

...

Command-Line Options

You can use the following command-line options to change the monitor configuration or to move windows automatically without displaying any user interface.

The <Monitor> parameter in all command-line options may contain the following values:

  • Primary - Specifies that you want to do the action on the primary monitor.
  • Monitor Name, as it appears in the 'Name' column, for example: \\.\DISPLAY1 , \\.\DISPLAY2, \\.\DISPLAY3
  • Monitor Number - The number that appears in the monitor name. (1 for \\.\DISPLAY1, 2 for \\.\DISPLAY2, and so on...)
  • Monitor ID, as it appears in the 'Monitor ID' column, for example: MONITOR\GSM59A4\{4d36e96e-e325-11ce-bfc1-08002be10318}\0008

/disable <Monitors> - Disables the specified monitors. You can specify a single monitor or multiple monitors.

Examples:

MultiMonitorTool.exe /disable 1
MultiMonitorTool.exe /disable \\.\DISPLAY3
MultiMonitorTool.exe /disable 1 2 3 

/enable <Monitors> - Enables the specified monitors.

Examples:

MultiMonitorTool.exe /enable 3
MultiMonitorTool.exe /enable \\.\DISPLAY1
MultiMonitorTool.exe /enable 3 2

Source MultiMonitorTool.

There are more MultiMonitorTool commands. See the source link above for more information.


Disclaimer

I am not affiliated with nirsoft in any way, I am just an end user of their software.