Remote Desktop connection in command prompt
The Remote Desktop Connection (RDC) tool, also known as Microsoft Terminal Services Client (MSTSC), allows a user to connect to another computer remotely over the network using the Remote Desktop Protocol (RDP). Most users use this tool via its Graphical User Interface (GUI) which is convenient to use, but this article focuses on using the Remote Desktop via the command line. Show
Connecting to other computers using RDC through the command line allows you to control different settings and preferences of the connection. Windows allows a user to use certain switches to predefine the settings before the connection is made. For example, you can define the name or IP address of the remote computer, or adjust the RDC window size even before running the tool. Learn how to enable RDC in Windows 11. Let us help you become aware of the switch options and how you can use them to configure your RDC connections. MSTSC commands and switchesThe conventional way to open the RDC in Windows is by searching for “Remote Desktop Connection” or “RDC” in Run and open the tool. This then opens the RDC tool where you can enter the name of IP address with port number (optional) of the remote computer that you want to connect to. Most of you would already be aware of this method. This section covers the possible commands and switches that you can use with RDC via the command line. We shall start with the most basic ones and then continue. Launch RDC from RunThe very basic command to run Remote Desktop Connection from the command line is via Run. Simply type in the following in Run and hit Enter. mstscRunning this will open the RDC with a blank text field. However, with the addition of a few switches, you can change the settings and preferences of the RDC connection. Let us continue forward with a few examples. Use RDC to connect via consoleAlthough RDC fully supports GUI, you can also connect to remote machines through a console. This will help in case you wish to continue the session that you got disconnected from earlier. In contrast, a regular GUI-based RDC session creates a new session each time you connect to the same machine. Use the following command to connect to a remote computer via console: mstsc /consoleLaunch RDC with IP addressYou can also launch RDC along with the IP address of the machine to connect it with. If the port on the machine is changed from the default value, you can also add the port number. Use the following commands to do so: mstsc /v:IPAddressmstsc /v:IPAddress:PortNumberReplace IPAddress with the complete IP address of the remote computer that you want to connect with, and PortNumber with the port number if changed from its default value. Launch RDC with computer nameYou can also connect to the remote computer by its unique computer name. The switch used for this is the same one used with the IP address and port number in the steps above. mstsc /v:ComputerNameReplace ComputerName with the unique name of the remote device that you can find in its settings or properties. Launch RDC in full-screen modeYou can also launch the RDC connection in full-screen mode. Here is how: mstsc /fThese switches can be combined into a single command to execute an RDC connection to your preferences. Here is an example: mstsc /f /v:192.168.10.122:8002MSTSC commands and switchesThere are more commands and switches you can use with mstsc command-line to adjust your settings for the connection beforehand. Here is the complete list:
These switches can have the following syntax in either Run or the Command Prompt: mstsc [The parameters in the alligator brackets (< and >) are variables that you can adjust according to your preferences. Troubleshoot RDC via command lineYou can also troubleshoot Remote Desktop services through the command line. For example, if you are unable to connect to a device using the GUI RDC but have access via console, you can check whether there are any configurations to be made that will connect you via GUI successfully. Check if RDP is enabled from Command promptLearn how to enable RDP remotely. You can run the following command to check the status of your device if RDP is enabled or disabled: netstat /p tcp /a | findstr 3389If the results come back as “Listening,” it means that RDP is enabled. Check if RDP is enabled from PowerShellAnother method to check whether RDP is enabled is through Windows PowerShell. You can run the following commands in PowerShell and it will tell you whether the service is available or not. if ((Get-ItemProperty "hklm:\System\CurrentControlSet\Control\Terminal Server").fDenyTSConnections -eq 0) { write-host "RDP is Enabled" } else { write-host "RDP is NOT enabled" }If the script returns “RDP is enabled,” it means that it is. Frequently Asked QuestionsMicrosoft Terminal Services Client (MSTSC) is a tool that allows a user to remotely connect to another device over the network as if they were physically present on the remote device. You can open the Remote Desktop Connection window from Run or Command Prompt using mstsc. You may also add switches like /v and /f to control the connection’s arguments. You cannot add a username or password directly to the mstsc command. However, you can store the credentials in a generic key against the machine you want to connect to using these 2 commands: Remote Desktop Connection (RDC) is a tool used to establish a remote connection between devices. Remote Desktop Protocol (RDP) is the technology that RDC uses to create this remote connection. Also see: |