Wednesday, March 19, 2014

Run command for remote desktop (RDP client)

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.
If you are connecting to a Windows XP machine then it allows only one active user at a time. We can open multiple connections to a Windows Server 2003/ 2008 machine. 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
We need to add /f switch to mstsc command.


mstsc /f
Run command for specifying the remote computer name from the command itself
we need to 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.

Enabling and Disablind of Remote connection through command prompt

Enable remote desktop from command line (CMD)

Remote desktop can be enabled/disabled by opening My computer properties and then by changing the settings in the ‘Remote‘ tab. We can do the same by editing registry key settings. This is explained below. Remote desktop is also called Terminal services or TS or RDP. This is an in-built remote desktop software for Windows users.
To enable remote desktop.
  • Open registry editor by running regedit from Run.
  • Go to the node HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server
  • Change the data of the value fDenyTSConnections to 0.
We can enable remote desktop from windows command line by running the following command.
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
To disable remote desktop we need to run the below command.
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 1 /f
Reboot or logoff is not required after running the above command. I have tested this on Windows XP and Windows 7 and it has worked fine. It would work fine on Windows Vista too.
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fAllowToGetHelp /t REG_DWORD /d 1 /f