21

I want to change the Display Arrangement of my computer via Command line. I have 2 monitors set up, extending, and I want to change the monitors setup from Dual Display to Single Display and back via command line.

I've had a look through QRes and nircmd. While QRes lacks multimonitor support entirely, nircmd cannot disable a monitor, only change the primary state and the resolution of separate screens.

It would be appreciated if you know of a way to do that.

Edit: I will post my solution here using the display changer in climenoles answer:

@echo off
REM setting to single screen
echo *** Disabling Screen 2 *** 
cd C:\Program Files (x86)\12noon Display Changer\
dc64cmd.exe -monitor="\\.\DISPLAY2" -detach

echo Starting TF2 -fullscreen -novid -console -w 1920 -h 1200
REM Starting Team Fortress 2 fullscreen
cd C:\Program Files (x86)\Steam
Steam.exe -applaunch 440 -fullscreen -novid -console -w 1920 -h 1200

REM pausing because steam.exe returns before TF2 quits
echo Press a key to reenable Screen 2
pause
cd C:\Program Files (x86)\12noon Display Changer\
dc64cmd.exe -monitor="\\.\DISPLAY2" -secondary
private_meta
  • 2,474

10 Answers10

27

Big thanks to Bill Rodman's comment in this thread.

I combine this utility with the Windows7 DisplaySwitch.exe command: "C:\Windows\System32\DisplaySwitch.exe /internal" to switch exclusevely to the main monitor. – Bill Rodman Jan 29 '10 at 12:17

Testing this out, this calls and immediately selects the screen to choose via the.

  • /internal calls the internal screen (your primary display)
  • /external changes to the external screen (im not sure how well it handles when there is more than 1 screen)
  • /clone duplicates displays.
  • /extend switches to extended settings.

Since this is calling a file path, simply attach this to your batch script and baboom, instant and effective display changing. A good idea would be to string this togethor into windows Task Scheduler UI as you can call the file path, and give it the arguments, then whenever your TF2 event happens, the display will always switch.

13

You were close with NirCmd, but what you're looking for is Nir's MultiMonitorTool:

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.

The 12noon tool looks nice, but barring an official MS tool, I'll take NirSoft over any other tool any day.

Shameless plug: You may be interested in the TvGameLauncher tool I wrote for exactly this purpose (switching primary displays for playing games). It can also switch to HDMI audio and prevent the screensaver from popping up while you're playing (without disabling it). It even supports the Steam protocol (Steam://) so you don't have to use the pause trick. It doesn't support disabling your other monitors though, but I'll add that to my todo list (I have some other cool features coming up like automatic TV shortcut generation).

Edit - all features added. Check it out!

8

This utility may help you: Display Changer :

«Display Changer changes the display resolution, runs a program, then restores the original settings. It can also change the resolution permanently and rearrange the monitors in a multiple-monitor setup»

Works in GUI or command line and it's free for personnal use...

http://12noon.com/?page_id=80

Hope this help. Let us know.

climenole
  • 3,516
  • 1
  • 22
  • 30
3

While I realize this is an old thread, toggling between display modes in Windows 10 using tools available by default is possible. The problem I ran into was there was no "clear" mechanism to tell that the display was Extended, vs. Cloned. Here is my working prototype in PowerShell:

#ext_or_clone.ps1
#Toggle between Extend and Clone displays
#requires PowerShell 3

#Load Windows Forms .Net class
#if PowerShell < 3 use this instead: [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
Add-Type -AssemblyName System.Windows.Forms

#check the width of the virtual display, the "mode" width 
$currDispMode = [System.Windows.Forms.SystemInformation]::VirtualScreen.Width

#check the width of the primary display
$oneScrWidth = [System.Windows.Forms.SystemInformation]::WorkingArea.width


#compare the two widths
switch ($currDispMode)
{
    #if the widths are the same,
    # it means the displays are in clone mode, so the mode should be extend
    $oneScrWidth{displayswitch.exe /extend}

    #if the VirtualScreen width is greater than the primary screen width
    # it means displays are in extend mode, so the mode should be clone
    {$_ -gt $oneScrWidth}{displayswitch.exe /clone}
}
DTE-IT
  • 31
2

WizardSoft's WS Display Settings is a neat little tool and pretty simple to use for command line newbies:

Command line tool to save and restore Windows display settings to and from file. Easy multi-monitor setup. Create presets for laptop, tv, monitor and beamer. It can save and restore the exact binary representation of the current Windows display settings.

What I wanted was a shortcut to switch to extended and another to go back to single display. After 30 minutes of mucking around with it - success!

I used Windows 7 and after reading readme.txt you could easily set this up too.

The simplest way to use the tool is to save the current display settings to a file with

WsDisplaySettings.exe -save filename.dis

and load & apply the settings with

WsDisplaySettings.exe filename.dis

There are also more advanced features, as explained in the readme file.

If I ran a business I would pay for the program! (It's free for personal use.)

robinCTS
  • 4,407
andrew
  • 21
2

You can use DisplaySwitch.exe /internal to change the display settings to use only your primary monitor, and DisplaySwitch.exe /extend to switch back to your multi-monitor setup. More info here. Works on Windows 10, too.

1

Another good one is wsdisplaysettings. Command line tool to setup displays to your liking. Can also create settings files for convenience.

kenorb
  • 26,615
John
  • 11
0

I have a laptop and an external monitor, so I call displayswitch.exe /external to only use the extended monitor and displayswitch.exe /extend to use both.

Also, to use both monitors for one user and turn off the internal monitor when the screen gets locked, I added windows tasks that gets triggered on workstation lock and unlock:

enter image description here

The one on lock has "Run with highest privilege" flag turned on.

0

Just found the easiest way to switch from dual monitors to one and back is **DisplayConfig ** in PowerShell. Here are the steps to get it:

  1. Install DisplayConfig: run in PS "Install-Module -Name DisplayConfig"
  2. To see all available monitors run in PS "Get-DisplayInfo" PS C:\Users\michaelc> Get-DisplayInfo

DisplayId  DisplayName   Active Primary Position Mode             ConnectionType           
        1  DELL P2419H   True   True    0 0      1920x1080@60Hz   DisplayPort
        2  DELL P2419H   True   False   -1920 0  1920x1080@60Hz   DisplayPort
        3  DELL P2317H   False  False   0 0                       DisplayPort
  1. To enable monitor N3 run in PS "Enable-Display 3"
  2. To disable monitor N3 run in PS "Disable-Display 3"
Monya
  • 1
-1

wow exactly what I was looking for my 3x1 setup on Win10. A straight-forward tray icon with 3 actions:

  • all Monitors ON full span display
  • only my middle monitor ON (left and right OFF)
  • only my right Monitor ON (left and middle OFF)

Kudos Andrew :-)