categories
Updated on in

Remote Desktop (RDP) Administration & MSTSC Commands: A Comprehensive Guide

Author: Helga York
Helga York Article author

One of the most long-standing and major features of Windows is Remote Desktop. To run Microsoft’s Remote Desktop Protocol (RDP) client, a command-line interface called Microsoft Terminal Services Client (MSTSC) is used.

These command-line options allow users to enable Remote Desktop connection, and remotely connect with another computer or a Remote Desktop Session Host server with the same level of fluidity and control as one would experience if they were physically operating the remotely accessed machine.

Users can also edit pre-existing Remote Desktop Connection (RDC) “.rdp” configuration files.

MSTSC command lines are used within the Windows command line.

Learn different RDP command-line options and some essential command-line tools, and find out how to use some popular commands for remote control.

Enhance RDP Experience with Critical MSTSC Command-Line Flags

The most common MSTSC command line arguments used are “/v” and “/f”. Users can enact the command to create almost instantaneous connections to a remote computer sharing a network using the Internal Protocol (IP) address.

Please Note:  When using a computer’s name to remotely access that machine, users must share the same network. Otherwise, users must have already configured DNS (or set up within a host file).

The MSTSC syntax is as follows:

MSTSC [<connection file> ] [/v:<server[:port]> ] [/g:<gateway> ] [/admin] [/f[ullscreen]] [/w:<width> /h:<height> ] [/public] |
[/span] [/multimon] [/edit "connection file"] [/restrictedAdmin] [/remoteGuard] [/prompt] [/shadow:<sessionID> [/control][/noConsentPrompt]]

Some important MSTSC commands you can use to make the most of your RDP experience: 

<connectionfile>
The name of the .rdp file needed to establish a connection
  /v:<server[:port]>
The remote computer or server you want to connect to
  /g:<gateway>
The RD Gateway Server utilized for the connection. Needed only if/when the endpoint remote PC is specified with “/v”
  /admin
Establish the connection as administrator
  /f
View the Remote Desktop Window in full-screen mode
  /w:<width>
Specify the width of the Remote Desktop Window
/h:<height>
Specify the height of the Remote Desktop Window
/public
Run Remote Desktop Connection publicly
/span
Match the width and height of the Remote Desktop to the local desktop
/edit <connectionfile>
Edit the specified “.rdp” file
/multimon
Make the monitor layout of the Remote Desktop Services session identical to the client-side configuration
/restrictedAdmin
Connect to the remote PC in the Restricted Administration mode. The credentials are not sent to the remote PC in this mode, meaning you are protected if you connect to a compromised PC
/remoteGuard
Connect your device to a remote device via Remote Guard, which prevents credentials being transmitted to a remote PC
/prompt
Prompts you to enter credentials to connect to the remote PC
/shadow:<sessionID>
The ID of the session to be shadowed
/control
Permits control over the session when shadowing
/noConsentPrompt
Permits shadowing without user consent
/migrate
Migrate legacy connection files created with Client Connection Manager to new .rdp connection files
/?
Displays help in the command prompt.

MSTSC /admin command

In the current version of Remote Desktop Connection (RDC), when Remote Desktop Session Host (RDSH) role service is installed on the remote machine, running “mstsc /admin” will establish the connection as an administrator and disable do the following for this connection only:

  •  Remote Desktop Services client access licensing;
  •  Time zone redirection;
  •  RD Connection Broker redirection;
  •  Remote Desktop Easy Print;
  •  Plug and Play device redirection;
  •  Alters the remote session theme to Windows Classic View (if available).

Open connection in full screen

Via the run app (or shortcut), users would usually open an RDP connection using the remote computer’s name or an IP address:

mstsc /v:computer_name /f
mstsc /v:192.168.123.123 /f

mstsc command full screen

Set height and width for the connection screen

The users seeking to assign/force height and width for the remote desktop screen should check out the following cmd line option example:

mstsc /v:192.168.255.255 /w:1024 /h:768
mstsc /v:192.168.255.255 /w:1600

How To Span Across Multiple (2+) Monitors

The noticeable struggle when remotely accessing the computer is that users can only see one of the monitors during the RDP connection. To have some additional space to fit a dual-monitor setup, users can use the “/span” command: “mstsc /v:192.168.123.123 /span”

For anyone who intends to use the “/span” command, the remote desktop window is treated as one continuous monitor.

Note: 

Some troubleshooting tips to consider:

• For quick help, run mstsc /?.

• If your connections fail, delete corrupted .rdp files.

• For logs, check Event Viewer (TerminalServices-ClientActiveXCore).

• Check both the Group Policy and firewall permit DP connections.

Important Command-Line Tools for Efficient RDP Administration

Administrators are required to complete different system management tasks after the connection is set up with the help of MSTSC. Although generic, these Windows commands are critical if you seek effective remote control. These commands are executed within an RDP session’s command prompt. 

General System Commands

These commands are used for basic network operations and give important system information. You can use these insights to perform essential tasks without dealing with a complex GUI. 

  • • Verify system data
    • systeminfo
    • ⚬ Show system data comprehensively, including the version of the operating system, hostname, architecture, boot time, and more.
  • • Check IP settings
    •  ipconfig /all
    • ⚬ It shows detailed info on network adapter configuration, such as IP addresses, gateways, DNS servers, subnet masks, etc.
  • • Validate network connectivity
    • ping google.com
    • ⚬ Send ICMP echo requests to check the connectivity between a target host and your system. The response times indicate network activity.
  • • Trace the network route
    • tracert 8.8.8.8
    • To diagnose routing issues, trace the route packets. See how each packet moves to reach a target host along the way 

Commands for File Management

In system administration, file management is crucial. There are efficient ways in the command line to manage files and directories in an ongoing RDP session. You can navigate the file system, create, delete, and manage files using these commands without relying on the GUI. 

  • • To navigate directories
    • cd <directory name/path>
    • ⚬ The command changes the current directory to the path specified. 
  • • To list files & directories
    • dir
    • ⚬ It shows all files and directories as well as their size and modification date in the current directory.
  • • To create a directory
    • mkdir ProjectFiles
    • ⚬ It allows you to create a new directory in the current path.
  • • Delete a File
    • del <filename>
    • ⚬ You can use this command to delete a file from a directory.
  • • To delete a directory
    • rmdir <directory name> /s /q
    • ⚬ Use this command with caution to remove a directory and its contents recursively.
  • • To copy Files
    • copy <source file> <destination folder>
    • ⚬ This is used to copy files between two locations.
  • • To move Files
    • move <source file> <destination folder>
    • ⚬ You can move your files from one place to another using this command.
  • • To rename files or directories
    • rename <old name> <new name>
    • ⚬ To change the name of a file or directory, use this command. 
  • • To search files
    • dir <search pattern> /s
    • ⚬ Enter this command to find files or directories matching a given pattern.

Commands for User Management

User management is another important part of system administration. It’s particularly useful when it comes to adding new users, fixing account-related issues, managing user permissions, etc., during an RDP session. Administrators can easily manage user accounts using these commands without facing the difficulties with complex GUIs.

  • • To view all user accounts
    • ⚬  net user
    • ⚬  This command is used to list all user accounts on the system.
  • • To obtain detailed user data 
    • net user <user name>
    • ⚬  It shows the data about a user account in detail. 
  • • To create a new user
    • net user <user name> <password> /add (e.g., net user JohnDoe Pa$$w0rd /add)
    • ⚬ Use it to create a new user account and assign it a name and a password.
  • • To delete a user account
    • ⚬  net user <username> /delete
    • ⚬  To delete a user account from a system, use this command. 
  • • To change a User Password
    • ⚬  net user <user name> <new password>
    • ⚬  Use this command to modify an existing user’s password.
  • • To lock/disable a user account
    • ⚬  net user <username> /active:no
    • ⚬  Prevent a user from logging in by disabling the account with this command. 

Advanced Commands

These are advanced commands that allow administrators to perform comprehensive settings, diagnostics, or system management. These open important Windows management tools.

  • • Windows Event Viewer Logs
    • eventvwr
    • ⚬ It opens the Event Viewer. It helps you check application and system logs to check warnings and errors.
  • • Windows Services Manager 
    • services.msc
    • ⚬ This command opens the Windows Services Manager. It helps you configure, start, or stop Windows services.
  • • Registry Editor
    • regedit
    • ⚬ This command opens the Windows Registry Editor. Use this cautiously to view the system registry and or edit it.
  • • Group Policy Editor
    • gpedit.msc
    • ⚬ It’s used to open the Group Policy Editor. This helps you manage and configure system policies, which come in handy while enforcing security policies and measures.
    • As you can see, utilizing Remote Desktop command-line options open up a plethora of customization, convenience, and opportunity when using RDP. We hope this guide has provided you with the insight and confidence necessary to start experimenting with MSTSC commands to enhance your remote desktop experience.