How to Enable Terminal Services / Remote Desktop Remotely (and in bulk)

The state of remote desktop is stored in the DWORD value HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\fDenyTSConnections

  • 1 = Disabled
  • 0 = Enabled

Although you could connect to the remote registry and make the change a reboot will be required to enable it, a better alternative is to use WMI (Windows Management Instrumentation), Windows provides a handy WMI command line tool in the form of WMIC. To enable remote desktop to server MyServer:

  1. wmic /node:”MyServer”RDToggle where servername=”MyServer”call SetAllowTSConnections 1

alternatively also specify a username and password for the remote system

  1. wmic /node:”MyServer” /user:”username” /password:”password” RDToggle where servername=”MyServer” call SetAllowTSConnections 1

Note that an exception for Remote Desktop will also be added to the firewall exception list.

Have a few servers to enable? Try:

  1. for %s in (MyServer1, MyServer2, MyServer3) do wmic /node:”%s” RDToggle where servername=”%s” call SetAllowTSConnections 1

Or a text file with a list of servers (file.txt), one per line? Try:

  1. for /f %s in (file.txt) do wmic /node:”%s” RDToggle where servername=”%s” call SetAllowTSConnections 1
This entry was posted in Windows Tips & Tricks and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *