Command Line to Enable Remote Desktop Remotely

I often use Remote Desktop to log on to a remote Windows machine and perform some admin tasks. The only problem is that this is not enabled by default. If your users do not have the admin privilege, they cannot turn it on for you. You may have to physically go to the machine yourself and turn on Remote Desktop, which defeats the purpose of using Remote Desktop.

Back in the days of XP, I had a script  that used wmic to turn Remote Desktop on remotely from a Windows 2003 server. This is the script.

wmic /node:remote_machine RDTOGGLE Where ServerName="remote_machine" Call SetAllowTSConnections 1

This works well for turning on Remote Desktop for XP machines; however, it does not work at all for Windows 7 machines.

Later on, I found this article about enabling remote desktop remotely by using registry, and it works well for Windows 7 machines. However, I am not satisfied with this solution because you need to invoke regedit, and there are a lot of steps to follow. It is fairly tedious and time consuming. I tried to achieve the same result using a command called reg, and I was able to do it by using command prompt. Here is an example of the command.

reg add "\\remote_machine\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f

Remember to replace the remote_machine with the machine name of your choice. You’ll need to run this in an elevated command prompt, otherwise you’ll get an error.


This post may contain affiliated links. When you click on the link and purchase a product, we receive a small commision to keep us running. Thanks.


Be the first to comment

Leave a Reply