11

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
  • Your post actually gave me the idea for this feature I added to TvGameLauncher. Check it out if still relevant (See my answer below). – Ohad Schneider Jul 12 '14 at 17:58
  • Hey, I know this question is old but I want to know if there is a way to detect the presence of another monitor in Windows from Command line? – Durga Swaroop Jul 21 '16 at 6:00
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.

  • Upvote for a good answer, but it will not work that way. I am trying to launch a Steam game that way. Launching it via the "steam://rungameid/#" does not work as it gives you no executable. running steam.exe with the -applaunch # option changes the resolution, does not start the game and immediately changes back (so fast you hardly see it). running the game executable directly leads to a loading error. Nice idea, yet it didn't work. – private_meta Feb 28 '12 at 17:42
  • But I just realized I can create a batch file with the initial command to change to one screen, start the game in a separate command line and then change back after the program terminates, all within a batch, that should theoretically work. I'll have to try that. – private_meta Feb 28 '12 at 17:44
  • Okay. Tell us if this works for you. If the batch works well you may compile it to have an .exe file With this for example: batchcompiler.sourceforge.net :) – climenole Feb 28 '12 at 18:14
  • Thank you. That works perfectly fine, except for the fact that steam.exe returns immediately, so I have to use "pause" or the batch won't work. – private_meta Feb 29 '12 at 20:42
6

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.

  • Works without administrator rights, works at 1 click distance. – erm3nda Sep 16 at 23:00
5

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!

  • 1
    NirSoft rocks. I've just had to find a solution to switch my monitors. I have a two-monitor setup, when one of them on and other is off. So no any fancy extended desktop mode etc. With MultiMonitorTool, now I have just a single one-liner: MultiMonitorTool.exe /switch 1 /switch 2 which switches off currently running monitor and at the same time turns off other. I put this command to my keyboard's macros key and now monitors are getting switched via a single keystroke! – TranslucentCloud Feb 12 '17 at 14:27
  • MultiMonitorTool worked poorly for me with different configurations of 3 monitors: some disabled, cloned, etc. It applied some configurations with a resolution of 0x0, which caused Nvidia Control Panel to not be able to open. – NateS Nov 8 '17 at 1:52
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}
}
1

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

1

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.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.