If you launch Remote Desktop frequently—especially after connecting to VPN—starting mstsc.exe from the command line or a batch file is faster and easier to standardize. This guide explains the core syntax, practical command patterns, and safe automation steps.
Originally published on 2009-06-20; fully revised and updated.
Source post: How to run Remote Desktop Console by using command line.

What mstsc.exe does
mstsc.exe is the Microsoft Remote Desktop Connection client executable. From the command line, you can connect to a remote host, open or edit an existing .rdp file, choose display settings, and run repeatable connection commands in scripts.
Core syntax
The original article provided the following syntax:
mstsc.exe {ConnectionFile | /v:ServerName[:Port]} [/console] [/f] [/w:Width /h:Height]
mstsc.exe /edit "ConnectionFile"
mstsc.exe /migrateCode language: PHP (php)
ConnectionFile: Name of an.rdpfile./v:ServerName[:Port]: Remote computer and optional port./console: Console-session switch (documented in the source for Windows Server 2003 family)./f: Full-screen mode./w:Width /h:Height: Custom window dimensions./edit "ConnectionFile": Open an.rdpfile for editing./migrate: Migrate legacy Client Connection Manager files to newer.rdpfiles.
Common command patterns
| Command | Best for | Example |
|---|---|---|
| Direct host connection | Quick ad-hoc connection | mstsc /v:server01 |
| Full screen | Dedicated admin session view | mstsc /v:server01 /f |
| Custom display size | Fixed-size remote window | mstsc /v:server01 /w:1440 /h:900 |
| Console session (legacy) | Older console-session workflows | mstsc /console |
| Edit saved RDP profile | Update connection settings | mstsc /edit server01.rdp |
| Migrate legacy files | Old client connection migrations | mstsc /migrate |
Automate launch from a batch file
If you connect over VPN first, a small batch script can make your workflow repeatable.
@echo off
set SERVER=server01
set RDP_FILE=%USERPROFILE%\Documents\server01.rdp
rem Option 1: direct server connection in full screen
mstsc /v:%SERVER% /f
rem Option 2: use a saved RDP profile
rem mstsc "%RDP_FILE%"Code language: CSS (css)
Typical command-line connection workflow
flowchart TD
A[Connect VPN if required] --> B[Run mstsc command]
B --> C{Use saved rdp file}
C -- Yes --> D[Open rdp profile]
C -- No --> E[Connect with server switch]
D --> F[Authenticate]
E --> F
F --> G[Remote desktop session starts]
Console-session compatibility note
The original post specifically ties /console to the Windows Server 2003 family. On newer Windows versions, behavior can differ by OS and RDP client build, so verify supported switches in your environment before standardizing scripts.
mstsc /?
Best practices
- Use saved
.rdpfiles for repeatable settings and easier handoff between admins. - Validate command switches with
mstsc /?on the exact Windows version you operate. - Keep batch scripts simple and readable; document server names and intent.
- Ensure you have the required administrative privileges for console-style sessions.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals
One area that deserves attention with remote desktop command-line usage is how organizations manage access at scale. A quick connection method may solve immediate administration needs, but without proper identity management, permission control, and activity tracking, it can introduce security and compliance challenges. Remote access should be treated as part of the overall infrastructure management process rather than just a troubleshooting shortcut.
For larger environments, teams can improve reliability by combining remote administration with centralized monitoring, access policies, and automation wherever possible. Maintaining clear records of remote sessions and regularly reviewing who can access critical systems helps reduce operational risks and creates a more controlled support process.