Skip to content

RDP how-to

MSTSC command guide: every switch with examples

mstsc starts Remote Desktop Connection from the command line. These are its switches, what each one does, and examples you can copy.

RyzenRDP guide cover: MSTSC command guide: every switch with examples

Key takeaways

  • mstsc /v:server:port connects to a server, with an optional port.
  • /admin opens a session for administering the server; /f goes full screen; /w and /h set the window size.
  • /multimon mirrors your monitor layout; /span stretches one desktop across side-by-side monitors of the same resolution; /l lists monitor IDs.
  • /shadow:ID /control lets an administrator view or control another session on the same server.
On this page
  1. What mstsc is
  2. Basic syntax
  3. Connect to a server and port with /v
  4. Admin sessions with /admin
  5. Full screen, size and /span
  6. Multiple monitors with /multimon
  7. Saving .rdp files
  8. Shadowing a session

What mstsc is

mstsc.exe is the Remote Desktop Connection client built into Windows. Typing mstsc in the Run box (Win+R), Command Prompt or PowerShell opens the familiar connection window; adding switches lets you connect, size and configure the session in one line, or from a shortcut or script. It is the quickest way to reach a Windows Server VPS from a Windows PC.

Basic syntax

mstsc.exe [<connectionfile>] [/v:<server>[:<port>]] [/g:<gateway>] [/admin] [/f] [/w:<width> /h:<height>] [/public] [/span] [/multimon] [/l] [/restrictedAdmin] [/remoteGuard] [/prompt] [/shadow:<sessionID> [/control] [/noConsentPrompt]]
mstsc.exe /edit <connectionfile>
Switch What it does
<connectionfile> Opens a saved .rdp file
/v:<server>[:<port>] The computer to connect to, with an optional port
/g:<gateway> The Remote Desktop Gateway to connect through (used together with /v)
/admin Connects to a session for administering the server
/f or /fullscreen Starts in full-screen mode
/w:<width> /h:<height> Sets the window size in pixels
/public Public mode: passwords and bitmaps are not cached on this PC
/span Stretches one remote desktop across side-by-side monitors of the same resolution
/multimon Uses your monitors with the same layout as on your PC
/l Lists your monitors and their IDs
/edit <file> Opens an .rdp file for editing
/restrictedAdmin Restricted Administrator mode: your credentials are not sent to the remote PC (implies /admin)
/remoteGuard Remote Credential Guard: credentials stay on your device
/prompt Always asks for credentials
/shadow:<ID> Views another session on the server
/control With /shadow, takes control instead of only viewing
/noConsentPrompt With /shadow, skips the user's consent prompt where policy allows

Connect to a server and port with /v

mstsc /v:203.0.113.10
mstsc /v:203.0.113.10:3390
mstsc /v:rdp.example.com /prompt

Without a port, mstsc uses 3389. If the server listens elsewhere, add :port; see RDP port 3389 explained for how to check and change it.

Admin sessions with /admin

mstsc /v:203.0.113.10 /admin

Run dialog with the command mstsc /v:203.0.113.10:3389 /admin

/admin connects you to a session for administering the server, and replaced the old /console switch. Windows Server allows two simultaneous administrative sessions without Remote Desktop Services client access licences (RDS CALs); more simultaneous users need the RD Session Host role and CALs.

Full screen, size and /span

mstsc /v:203.0.113.10 /f
mstsc /v:203.0.113.10 /w:1600 /h:900
mstsc /v:203.0.113.10 /span
  • /f fills the current monitor.
  • /w and /h set a fixed window size, useful for screenshots or a side-by-side layout.
  • /span makes one wide desktop across monitors that have the same resolution and sit side by side. Vertical stacking is not supported for spanning.

Multiple monitors with /multimon

mstsc /v:203.0.113.10 /multimon
mstsc /l

/multimon gives the remote session the same monitor layout as your PC, so windows maximise per monitor, which suits traders and developers who keep different tools on different screens. To use only some monitors, run mstsc /l to see their IDs and put them in a saved .rdp file:

use multimon:i:1
selectedmonitors:s:0,1

Saving .rdp files

In Remote Desktop Connection, choose Show Options, set the computer, display and local resources, then Save As. Open the file later by double-clicking it, or with mstsc C:\Users\you\Documents\server.rdp. To change a saved file, run mstsc /edit server.rdp.

Useful lines inside an .rdp file:

full address:s:203.0.113.10:3390
screen mode id:i:2
use multimon:i:1

screen mode id:i:2 starts full screen; 1 starts in a window. Never store passwords in files you share.

Shadowing a session

An administrator can view, or with /control take over, another user's session on the same server:

query session /server:203.0.113.10
mstsc /v:203.0.113.10 /shadow:2 /control

query session (also qwinsta) lists session IDs. Shadowing needs administrator rights and is governed by the Group Policy Set rules for remote control of Remote Desktop Services user sessions (Remote Desktop Session Host > Connections). Unless that policy allows otherwise, the user is asked to consent; /noConsentPrompt only works where the policy permits it.

FAQ

What does mstsc /admin do?

It connects you to a session for administering the server. It replaced the older /console switch, and it is the switch to use when you manage a server rather than work on it as a normal user.

How do I connect to a custom RDP port with mstsc?

Add the port after a colon: mstsc /v:203.0.113.10:3390. The same address:port form works in the Computer box of Remote Desktop Connection.

How do I use mstsc with multiple monitors?

Run mstsc /multimon to use all your monitors with their current layout, or mstsc /span to stretch one desktop across horizontally aligned monitors of the same resolution. Use mstsc /l to list monitor IDs for the selectedmonitors setting.

Sources

  1. Microsoft Learn: mstsc command reference
  2. Microsoft Learn: Change the listening port for Remote Desktop
  3. Microsoft Learn: Troubleshoot Remote Desktop disconnected errors (two administrative sessions without RDS CALs)

Run Windows Server on AMD Ryzen or AMD EPYC

Full Administrator access, Remote Desktop ready, set up within 24 hours. Plans from $14.99/mo.