on October 30, 2018
The Run command for Windows Remote desktop application is Mstsc
Just open Run from start menu and type mstsc in the text box next to open and press enter.
This command mstsc
can be used from command line too.
A system running Windows 7/Windows 10 allows only one remote desktop connection at a time, means only one remote user can work on it any time. A computer running Windows server edition can support remote sessions for multiple users at the same time.
Mstsc command
Every time we connect to the server it opens a new user session. To avoid this we can open a connection to the console. This allows us to login back to the same user session if we already have one. To do this we need to add /console
switch to the mstsc
command.
mstsc /console
This command can be run from command prompt or from Run window.
Run command for opening remote desktop session in full screen mode
Add /f
switch to the command.
mstsc /f
Run command for specifying the remote computer name from the command itself
Use /v
switch in this case.
mstsc /v:computername
Run command to specify remote desktop connection settings using a rdp file
mstsc RDP_filename
A RDP file can be created using the ‘Save As‘ button in the General tab in mstsc(Remote desktop connection client) window.
These commands work on XP, Vista, Windows 7 and Server 2003/2008 operating systems.
Run command for Remote desktop manager
There is no Run command for opening remote desktop connection manager directly. It is usually installed in the path C:\Program Files\Remote Desktop Connection Manager\RDCman.exe
. By specifying this complete path we can launch connection manager.
Relevant Posts:
How to enable Remote desktop from command line
The Remote Desktop Protocol (RDP) is something Microsoft made since years ago. It lets you see and use another computer from yours over a network. Most people use the Remote Desktop Connection app (mstsc.exe
) that comes with Windows. But, if you like doing things with command lines, because you want more control or to write scripts (for example, to automate stuffs), there’s a way for that too.
In this guide, we’re going to look at how to use the command line to make an RDP connection, turn on remote access, and handle Remote Desktop sessions on Windows 11.
How to start an RDP connection with Command Prompt
The command prompt in Windows is a speedy way to start an RDP connection. You’ll use the mstsc
command, which stands for Microsoft Terminal Services Client, to do this.
After opening the command prompt, type this to begin a remote connection:
mstsc /v:yourRemoteComputer
Replace “yourRemoteComputer” with the IP address or computer name you’re connecting to. This way is quick because you don’t have to click through lots of menus.
Also see: How to Remote Desktop Over The Internet in Windows 11
Using the command line for remote desktop
The mstsc
command has many options to change how your Remote Desktop sessions work. For instance, /f
makes it full screen, and /admin
gives you admin rights.
mstsc /f /v:yourRemoteComputer
To see all options, type this:
mstsc /?
Handy tip: Windows 11: Check Who is Logged in Remotely or Locally
How to join the main session of a remote computer
The mstsc /console
or mstsc /admin
command in newer Windows versions helps you join the main session of a remote computer. This is great for certain apps or admin tasks that need the main session.
Here’s how to do it:
- Open the command prompt.
- Type this command and press Enter:
mstsc /admin /v:yourRemoteComputer
Change “yourRemoteComputer” to the computer’s name or IP you want to connect to.
This starts a session to the remote computer’s main session. But be careful, because this session might already be in use, and you don’t want to interrupt someone’s work.
Linked issue: Windows 11 Remote Desktop “An authentication error has occurred”
How to begin and end a remote desktop session
Handling Remote Desktop sessions is key for remote system care. The mstsc
command starts a session. To end it, just close the Remote Desktop window. Or, for more control, use command line ways to finish it.
The logoff
command ends a session. You need the session ID, which you find by typing query session
.
logoff SessionID
Useful resource: How to Install Telnet via CMD or PowerShell in Windows 11
Using a RDP file for remote desktop
.rdp files are Microsoft Remote Desktop config files that save settings for sessions. They’re handy for connecting to a computer with specific settings without entering them each time.
Here’s how to make a .rdp file:
- Open Remote Desktop Connection by typing mstsc in the command prompt or search bar and press Enter.
- In the window, put the remote computer’s name or IP in the “Computer” field.
- Click “Show Options” for more settings, like your username, display options, and more.
- After setting things up, click “Save As” under Connection settings.
- Save the .rdp file where you want, with a name you choose.
To use the .rdp file, type this command, swapping “C:\file.rdp” with your .rdp file’s location and name:
mstsc C:\file.rdp
This opens a Remote Desktop session with your saved settings. If you saved your login info in the .rdp file, it’ll log you in automatically; otherwise, you’ll need to type your password.
Turning on remote access in Windows 11
Before making a remote connection, the computer you want to connect to must have Remote Desktop turned on. While you can easily do this in Windows 11 settings, you can also use the command line with PowerShell for more direct control.
To turn on Remote Desktop with PowerShell, first open PowerShell as an admin. Type “PowerShell” in the Windows search bar, right-click the Windows PowerShell app, and choose “Run as administrator.”
Then, enable Remote Desktop with this command:
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0
How to run commands on a remote system
For system management, sometimes you need to run commands on another computer. Windows has a tool called PsExec
in the Sysinternals suite for this. After installing PsExec
, you can use it to run commands remotely like this:
psexec \\remoteComputer command
Replace “remoteComputer” with the remote computer’s name, and “command” with what you want to do.
To sum up
We’ve covered how to use the command prompt for Remote Desktop stuff in Windows 11. From basic connections to more detailed tasks like joining a computer’s main session, using the command line gives you lots of flexibility and efficiency for managing remote connections (especially useful if you’re a network admin).
Command lines are great for when you need to automate things, do lots of tasks at once, or work on computers without using the graphical interface. .rdp files help save session settings for later, and tools like PsExec
and the mstsc /admin
command give you more control over remote computers.
But, always use these commands wisely and correctly to avoid messing up someone else’s work or making the system less secure. Make sure your RDP connections are safe and only let trusted people access them.
Using Windows CMD to initiate a Remote Desktop Connection allows users to quickly connect to another computer over a network using the following command syntax:
mstsc /v:<IPAddress_or_ComputerName>
Understanding Remote Desktop
What is Remote Desktop?
Remote Desktop is a powerful feature that allows users to connect to and control a computer from a different location. This functionality is invaluable in various scenarios, such as accessing work computers from home, providing remote support, or managing servers without being physically present.
With Remote Desktop, users can see the desktop interface, run applications, and manage files just as if they were sitting right in front of the remote machine. Its flexibility and convenience make it a popular tool among IT professionals and everyday users alike.
The Role of CMD in Remote Desktop Management
While many users interact with Remote Desktop through the graphical user interface, leveraging the Command Prompt (CMD) can provide a more streamlined and efficient method for managing these connections. CMD allows for the execution of commands that can quickly configure settings, initiate connections, and troubleshoot issues without the need to navigate through various settings menus. This command-line approach is advantageous for experienced users and in scenarios where script automation can enhance productivity.
Windows Cmd Remove File: Quick and Easy Guide
Setting Up Remote Desktop on Windows
Enabling Remote Desktop
Before you can connect to a computer via Remote Desktop, you must ensure that the feature is enabled on the target machine. Here’s how you can enable Remote Desktop through the Windows settings:
- Navigate to System Properties by right-clicking on This PC and selecting Properties.
- Click on Remote Settings on the left sidebar.
- Under the Remote Desktop section, select Allow remote connections to this computer. Ensure that the option Allow connections only from computers running Remote Desktop with Network Level Authentication is checked for enhanced security.
- Apply the changes and note any additional prompts regarding firewall settings.
This process allows remote connections from specified users.
Using CMD to Configure Remote Desktop
You can enable Remote Desktop using a simple command in CMD. Open the Command Prompt with administrative privileges and run the following command:
reg add "HKLM\System\CurrentControlSet\Control\Terminal Server" /v "fDenyTSConnections" /t REG_DWORD /d 0 /f
This command modifies the Windows Registry to allow remote connections.
Configuring Firewall Settings for Remote Desktop
To ensure that your Remote Desktop connection can traverse the firewall, you must configure the Windows Firewall settings. The command below enables the necessary rules for Remote Desktop:
netsh advfirewall firewall set rule group="remote desktop" new enable=yes
By executing this command, you allow Remote Desktop connections through your firewall, ensuring smooth access.
Navigate Your Windows Cmd Home Directory Effortlessly
Connecting to Remote Desktop via CMD
Using the MSTSC Command
The Microsoft Terminal Services Client (MSTSC) is the command you will use to initiate a Remote Desktop session. To connect to a specific remote computer, use the following command:
mstsc /v:RemotePCName /admin
Replace `RemotePCName` with the actual name or IP address of the computer you want to connect to. The `/admin` flag is optional and allows you to connect without having a regular user session in progress.
Common Options for MSTSC
MSTSC supports various parameters that enhance functionality:
- /v:servername – Connects to a specified server or IP address.
- /f – Opens the connection in full-screen mode.
- /w:width /h:height – Sets the width and height of the window.
For example, to connect to a remote PC using a specific IP in full-screen mode, you could use:
mstsc /v:192.168.1.10 /f
This command connects to the machine at IP address 192.168.1.10 using full-screen mode.
Mastering Windows Cmd Route: A Concise Guide
Advanced CMD Techniques for Remote Desktop Management
Using PowerShell for Remote Desktop Operations
While CMD is powerful, PowerShell offers more advanced capabilities for managing remote desktop connections. You can initiate a PowerShell session for remote management using the following command:
Enter-PSSession -ComputerName RemotePCName
This command allows you to manage the remote system directly within your PowerShell session, utilizing scripts and advanced procedures.
Automating Remote Desktop Connections
One significant benefit of using CMD is the ability to automate routine tasks. By creating a batch script, you can quickly connect to a remote machine without manual input each time.
Here’s an example of a simple batch script:
@echo off
mstsc /v:192.168.1.10
Save this script with a `.bat` extension. Running it will connect you to the specified IP address effortlessly.
Mastering Windows Cmd Switches: A Concise Guide
Troubleshooting Remote Desktop Connection Issues
Common Issues and Solutions
Even with a correctly configured environment, users can encounter connection issues. A common problem may be the message stating, «Remote access is not enabled.» When this occurs, you should ensure that Remote Desktop is enabled and properly configured.
To check if the Remote Desktop Service is running, you can use the following command:
net start TermService
This command starts the Terminal Services, which is responsible for managing Remote Desktop connections.
Logging and Monitoring Remote Connections
Monitoring your Remote Desktop connections can help identify issues and enhance security. You can use the following command to view logs regarding Remote Desktop sessions:
wevtutil qe Microsoft-Windows-TerminalServices-LocalSessionManager/Operational
This command allows you to query the event logs specifically for Remote Desktop activities.
Windows Cmd Repair: Quick Fixes You Need to Know
Security Considerations
Best Practices for Secure Remote Desktop Connections
Security must always be a priority when dealing with Remote Desktop connections. Here are a few essential practices:
- Use strong, unique passwords for accounts that can access Remote Desktop.
- Enable Network Level Authentication (NLA) to ensure that only authenticated users can establish a remote session.
- Utilize a VPN when connecting over unsecured networks to encrypt your connection.
- Regularly update your system and firewall settings to protect against vulnerabilities.
Monitoring and Managing User Access
It’s critical to control who has access to your remote systems. To add a user to the Remote Desktop Users group, you can run the following command:
net localgroup "Remote Desktop Users" username /add
Replace `username` with the individual’s username you wish to grant access. This allows specific users to connect remotely while maintaining security.
Mastering Windows Cmd Version: Essential Tips and Tricks
Conclusion
In summary, mastering Windows CMD Remote Desktop offers valuable efficiencies when managing remote connections. Whether you are enabling Remote Desktop, initiating connections, or troubleshooting issues, CMD commands can significantly enhance your productivity and control. By understanding these commands and best practices, users can fully leverage the power of Remote Desktop technology to achieve seamless remote access.
Feel free to explore more CMD functionalities to further enhance your remote desktop management techniques.
Remote Desktop Protocol (RDP) is a feature in Windows that allows you to connect and control a remote computer from another device. Enabling Remote Desktops can be beneficial for IT administrators, professionals working remotely, and users managing multiple computers. While the graphical interface in Windows is a common way to enable Remote Desktop, using the Command Prompt (CMD) provides a faster, scriptable, and powerful alternative. This guide will walk you through how to enable Remote Desktop from CMD.
Using CMD to enable Remote Desktop offers several advantages:
- Speed: Quickly enable RDP without navigating through menus.
- Automation: Use scripts to enable RDP on multiple machines.
- Remote Management: Ideal for scenarios where you only have command-line access.
- Flexibility: CMD can access advanced settings that are not always available in the graphical interface.
Prerequisites
Before enabling Remote Desktop from CMD, ensure the following:
- You have administrative privileges on the computer.
- The computer runs a Windows version that supports remote desktops, such as Windows 10 Pro, Enterprise, or Windows Server editions.
- Ensure the Windows Firewall and network settings allow Remote Desktop connections.
Step-by-Step Guide How to Enable Remote Desktop from CMD
Step 1: Open Command Prompt as Administrator
- Click Windows + S to open the search bar.
- Type cmd & right-click on the “Order Prompt” result.
- Select Run as administrator.
Step 2: Enable Remote Desktop
To enable Remote Desktop, you need to modify the Windows registry and configure firewall rules. Here’s how:
1. Modify the Windows Registry
The registry key that controls Remote Desktop is located at:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server
Run the following command to enable Remote Desktop:
reg add "HKLM\System\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
- /v: Specifies the registry value name (fDenyTSConnections).
- /t: Specifies the type of the value (REG_DWORD).
- /d: Sets the value data to 0 (enables RDP).
- /f: Forces the operation without confirmation prompts.
2. Configure Network Level Authentication (Optional)
Network Level Authentication (NLA) enhances security by requiring users to authenticate before establishing a Remote Desktop connection. To enable NLA, run:
reg add "HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v UserAuthentication /t REG_DWORD /d 1 /f
Setting UserAuthentication to 1 enables NLA.
Step 3: Open Firewall Ports
Remote Desktop requires specific firewall rules to allow incoming connections. By default, RDP uses TCP port 3389. Use the following command to enable the necessary firewall rule:
netsh advfirewall firewall set rule comunitys="Remote Desktop Protocol (RDP)" new enable=yes
This command activates the pre-configured firewall rules for Remote Desktop.
If you’re using a custom port, you need to create a new rule. For example:
netsh advfirewall firewall join rule name="Custom Remote Desktop (RDP)" protocol=TCP dir=in localport=3389 action=permit
Replace 3389 with your custom port number if necessary.
Step 4: Verify Remote Desktop Settings
To confirm that Remote Desktop is enabled, you can:
-
-
- Check the registry value for fDenyTSConnections. Run:
reg query "HKLM\System\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections
If the output shows 0x0, Remote Desktop is enabled.
- Verify the firewall rules. Run:
netsh advfirewall firewall show rule name="Remote Desktop"
Ensure the rule is enabled and configured correctly.
- Check the registry value for fDenyTSConnections. Run:
-
Step 5: Enable Remote Desktop Services
If Remote Desktop still doesn’t work, ensure the Remote Desktop Services are running. Use the following commands:
- To start the Remote Desktop Services:
sc config TermService start= auto
sc start TermService
- To check the status of the service:
sc query TermService
The output should indicate that the service is starting.
Step 6: Connect to the Remote Computer
Once Remote Desktop is enabled, you can connect to the remote PC using the RDP client:
- Press Windows + R, write mstsc, & hit Enter.
- Submit the IP address or hostname of the RDP Personal Computer.
- Press Merger & log in with the adequate credentials.
Automating the Process with a Batch File
If you need to enable Remote Desktop on multiple machines, consider creating a batch file. Here’s an example:
@echo off rem Enable Remote Desktop reg add "HKLM\System\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f rem Enable Network Level Authentication reg add "HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v UserAuthentication /t REG_DWORD /d 1 /f rem Open Firewall for Remote Desktop netsh advfirewall firewall set rule comunity="Remote Desktop" new enable=yes rem Start Remote Desktop Services sc config TermService start= auto sc start TermService @echo Remote Desktop enabled successfully.
Save the file as EnableRDP.bat and run it as an administrator on each computer.
Troubleshooting
If Remote Desktop is not working after following the above steps, consider the following:
- Firewall Issues: Verify the firewall rules using netsh advfirewall firewall show rule name=”Remote Desktop”.
- Service Status: Ensure the TermService service is running.
- Network Configuration: Check that the remote computer’s IP address is reachable.
- Port Conflicts: Ensure no other application is using port 3389.
- Windows Version: Confirm that the remote computer’s Windows edition supports Remote Desktop.
Conclusion
Enabling Remote Desktop through CMD is a powerful method, especially for IT professionals managing multiple devices. By modifying the registry, configuring firewall rules, and ensuring the Remote Desktop Services are running, you can enable RDP efficiently. Whether for automation or troubleshooting, CMD provides a flexible and scriptable way to manage Remote Desktop settings.
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.
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.
Table of Contents
Let us help you become aware of the switch options and how you can use them to configure your RDC connections.
MSTSC commands and switches
The 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 Run
The 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.
mstsc
Running 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 console
Although 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 /console
Launch RDC with IP address
You 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:IPAddress
mstsc /v:IPAddress:PortNumber
Replace 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 name
You 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:ComputerName
Replace ComputerName with the unique name of the remote device that you can find in its settings or properties.
Launch RDC in full-screen mode
You can also launch the RDC connection in full-screen mode. Here is how:
mstsc /f
These 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:8002
MSTSC commands and switches
There 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:
<connectionfile> | For a .rdp file required to make a connection (if applicable). |
/v: | IP Address or computer name of the remote computer. |
/g: | IP Address or device name of a Remote Gateway Server (if applicable). |
/admin | To establish a connection with administrative privileges. |
/f | View the Remote Desktop Window in full-screen mode. |
/w: | To specify the width of the Remote Desktop Window. |
/h: | To specify the height of the Remote Desktop Window. |
/public | Run the Remote Desktop Connection publicly (less secure). |
/span | To match the width and height of the Remote Desktop with the local desktop. |
/edit <connectionfile> | To edit a .rdp file. |
/multimonTo make the monitor layout of the Remote Desktop Services session identical to the client-side configuration. | |
/restrictedAdmin | Connect to the remote PC in Restricted Administration mode. The credentials are not sent to the remote PC in this mode, protecting you if you connect to a compromised PC. |
/remoteGuard | Connect your device to a remote device using the Remote Guard, which prevents sending credentials to a remote PC. |
/prompt | To prompt you to put in credentials to connect to the remote PC. |
/shadow: | The ID of the session that you want to connect to. |
/control | Give control of the session when shadowing. |
/noConsentPrompt | To allow shadowing without user consent. |
/migrate | Migrate legacy connection files created with Client Connection Manager to new .rdp connection files. |
/? | To get help in the command prompt. |
These switches can have the following syntax in either Run or the Command Prompt:
mstsc [<connection file>] [/v:<server[:port]>] [/g:<gateway>] [/admin] [/f] [/w:<width> /h:<height>] [/public] | [/span] [/multimon] [/edit "connection file"] [/restrictedAdmin] [/remoteGuard] [/prompt] [/shadow:<sessionID> [/control][/noConsentPrompt]]
The parameters in the alligator brackets (< and >) are variables that you can adjust according to your preferences.
Troubleshoot RDC via command line
You 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 prompt
Learn 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 3389
If the results come back as “Listening,” it means that RDP is enabled.
Check if RDP is enabled from PowerShell
Another 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 Questions
What is MSTSC?
Microsoft 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.
How to open Remote Desktop from the command line?
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.
How to add username and password to mstsc command line?
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:cmdkey /generic:"<server>" /user:"<user>" /pass:"<password>"
mstsc /v:"<server>"
Is the RDP and RDC the same?
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.