{"id":129,"date":"2026-10-12T10:41:10","date_gmt":"2026-10-12T10:41:10","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2009\/06\/20\/how-to-run-remote-desktop-console-using-command-line\/"},"modified":"2026-10-12T10:41:10","modified_gmt":"2026-10-12T10:41:10","slug":"how-to-run-remote-desktop-console-using-command-line","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-run-remote-desktop-console-using-command-line\/","title":{"rendered":"Run Remote Desktop from the Command Line with mstsc.exe (Including Legacy Console Mode)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">If you launch Remote Desktop frequently\u2014especially after connecting to VPN\u2014starting <code>mstsc.exe<\/code> 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Originally published on 2009-06-20; fully revised and updated.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Source post: <a href=\"https:\/\/www.devopsschool.com\/blog\/how-to-run-remote-desktop-console-using-command-line\/\">How to run Remote Desktop Console by using command line<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2009\/06\/desktop-console-using-comma.png\" alt=\"Remote Desktop command line screenshot\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">What mstsc.exe does<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>mstsc.exe<\/code> is the Microsoft Remote Desktop Connection client executable. From the command line, you can connect to a remote host, open or edit an existing <code>.rdp<\/code> file, choose display settings, and run repeatable connection commands in scripts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Core syntax<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The original article provided the following syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php language-bash\">mstsc.exe {ConnectionFile | \/v:ServerName&#91;:Port]} &#91;\/console] &#91;\/f] &#91;\/w:Width \/h:Height]\nmstsc.exe \/edit <span class=\"hljs-string\">\"ConnectionFile\"<\/span>\nmstsc.exe \/migrate<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\"><li><code>ConnectionFile<\/code>: Name of an <code>.rdp<\/code> file.<\/li><li><code>\/v:ServerName[:Port]<\/code>: Remote computer and optional port.<\/li><li><code>\/console<\/code>: Console-session switch (documented in the source for Windows Server 2003 family).<\/li><li><code>\/f<\/code>: Full-screen mode.<\/li><li><code>\/w:Width \/h:Height<\/code>: Custom window dimensions.<\/li><li><code>\/edit \"ConnectionFile\"<\/code>: Open an <code>.rdp<\/code> file for editing.<\/li><li><code>\/migrate<\/code>: Migrate legacy Client Connection Manager files to newer <code>.rdp<\/code> files.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Common command patterns<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Command<\/th><th>Best for<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td>Direct host connection<\/td><td>Quick ad-hoc connection<\/td><td><code>mstsc \/v:server01<\/code><\/td><\/tr><tr><td>Full screen<\/td><td>Dedicated admin session view<\/td><td><code>mstsc \/v:server01 \/f<\/code><\/td><\/tr><tr><td>Custom display size<\/td><td>Fixed-size remote window<\/td><td><code>mstsc \/v:server01 \/w:1440 \/h:900<\/code><\/td><\/tr><tr><td>Console session (legacy)<\/td><td>Older console-session workflows<\/td><td><code>mstsc \/console<\/code><\/td><\/tr><tr><td>Edit saved RDP profile<\/td><td>Update connection settings<\/td><td><code>mstsc \/edit server01.rdp<\/code><\/td><\/tr><tr><td>Migrate legacy files<\/td><td>Old client connection migrations<\/td><td><code>mstsc \/migrate<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Automate launch from a batch file<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you connect over VPN first, a small batch script can make your workflow repeatable.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css language-bash\"><span class=\"hljs-keyword\">@echo<\/span> off\nset SERVER=server01\nset RDP_FILE=%USERPROFILE%\\Documents\\server01.rdp\n\nrem Option <span class=\"hljs-number\">1<\/span>: direct server connection in full screen\nmstsc \/<span class=\"hljs-attribute\">v:<\/span>%SERVER% \/f\n\nrem Option <span class=\"hljs-number\">2<\/span>: use a saved RDP profile\nrem mstsc <span class=\"hljs-string\">\"%RDP_FILE%\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Typical command-line connection workflow<\/h2>\n\n\n\n<pre class=\"mermaid\">\nflowchart TD\n    A[Connect VPN if required] --> B[Run mstsc command]\n    B --> C{Use saved rdp file}\n    C -- Yes --> D[Open rdp profile]\n    C -- No --> E[Connect with server switch]\n    D --> F[Authenticate]\n    E --> F\n    F --> G[Remote desktop session starts]\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Console-session compatibility note<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The original post specifically ties <code>\/console<\/code> 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.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs language-bash\">mstsc \/?<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Best practices<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Use saved <code>.rdp<\/code> files for repeatable settings and easier handoff between admins.<\/li><li>Validate command switches with <code>mstsc \/?<\/code> on the exact Windows version you operate.<\/li><li>Keep batch scripts simple and readable; document server names and intent.<\/li><li>Ensure you have the required administrative privileges for console-style sessions.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to launch Remote Desktop sessions from Command Prompt or batch files using mstsc.exe. This updated guide covers syntax, common command patterns, and legacy console-session behavior.<\/p>\n","protected":false},"author":1,"featured_media":4006,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[49],"tags":[333,824,3025,3021,3020,1122,545,3026,1806,593,3028,383,3027,3022,1668,3023,3024,1593,1097,104,1452],"class_list":["post-129","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general","tag-command","tag-command-line","tag-command-line-for-remote-desktop","tag-console","tag-desktop","tag-guide","tag-how","tag-how-to-run-remote-desktop-by-commands","tag-instruction","tag-process","tag-rdp","tag-remote","tag-remote-connection","tag-remote-desktop-console","tag-run","tag-run-command","tag-run-command-for-remote-desktop","tag-techniques","tag-tips","tag-tutorials","tag-ways"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=129"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":78978,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/129\/revisions\/78978"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/4006"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}