0

I am using Windows RDP (remote desktop) with a multi-monitor setup and I want my script to automatically detect the position of the monitors. Additionally, I only use some of my monitors for RPD with the selectedmonitors:s:x,y option in the .rdp file.

While the above method works, sometimes the remote display is in the incorrect left-right ordering on the two monitors. Depending on the order my laptop is connected to the HDMI cables the monitors are sometimes in order 0,1,2 and sometimes 0,2,1, e.g. the physical left-right order may (or may not) match Windows' logical numbering of the monitors. Currently, I run mstsc.exe /l that displays a GRAPHICAL dialog box with the monitors' positions, then hand edit the .rdp connection file with either selectedmonitors:s:1,2 or selectedmonitors:s:2,1.

Since the output from mstsc.exe \l is a GRAPHICAL dialog box I don't know how to pull the position information into a batch file. I would like to use a batch/PS script to query the monitor's (x,y) positions and adjust the .rdp file automatically.

Is there another switch for mstsc.exe or a different command to print the (x,y) positions as text or to stdout so I can parse it?

I'm in a corporate IT environment, so different remote desktop programs are not an option so need to use the tools that are available.

New contributor
Aaron Caba is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Answer 1

0

You can gather monitor information via PowerShell.

Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Screen]::AllScreens

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .