I have my TV hooked up to my PC, which also has its own monitors. I have a controller and wireless keyboard attached to the PC with Bluetooth when I control the PC from my couch, and a wired keyboard and mouse when I am at my desk. This set up woks great, except for the settings for the main monitor.
When I am on the couch and want to launch a program, it will launch on the main monitor (which is set to the monitor on my desk). That is not ideal, so I would want to be able to easily and seamlessly switch between main monitors. I am sure that there must be a command for this, in which case I can just add shortcuts to my desktop which, when clicked, switches the main monitor. I am looking for a bat, cmd, powershell kinda approach and would like to avoid third party software.
Can anyone help me out with that? Thanks
62 Answers
If a window ended up on the wrong monitor and the desktop is in extend mode, you may use Win+Shift+Arrow to move the active window left/right to previous/next monitor.
If you would like to change the primary monitor, you need to use a third-party product.
Below are some such free products. Where monitor number is used, you will need to find out, even by trial and error, what are the numbers for your monitors.
- NirSoft NirCmd :
nircmd.exe setprimarydisplay 1 - NirSoft MultiMonitorTool :
MultiMonitorTool.exe /SetPrimary 2 - Display Changer
All these products have a command-line mode, so you could use batch scripts. The scripts could be launched by icons on the desktop that may also have assigned hotkeys for easier usage.
2With the suggestion of @harrymc and help over at Stack Overflow, I wrote the following bat script which can switch between monitors. In my case display 1 is the default and it switches with display 3 whenever the script is executed.
@echo off SETLOCAL EnableDelayedExpansion IF EXIST active.txt ( set /p display=< active.txt del active.txt IF "!display!" == "1" ( nircmd.exe setprimarydisplay 3 echo | set /P ="3"> "active.txt" ) ELSE ( nircmd.exe setprimarydisplay 1 echo | set /P ="1"> "active.txt" ) ) ELSE ( nircmd.exe setprimarydisplay 1 echo | set /P ="1"> "active.txt" ) Save this script in a folder, e.g. C:\tools\switch_display\switch.bat and make sure that you also have nircmd.exe in that directory. You can then create a shortcut on your desktop to that script.