2020-03-31

The subject says it all. Many of the system admins know that flipping a registry key will enable or disable RDP connectivity on a Windows Server or desktop. However, modifying the registry is not always convenient. For those out there who thinks there should be much easier way, this post is for them

You can enable RDP on a remote host by simply running the below two lines.

You can also disable it using the below method.

Do you care to check if it is currently enabled or disabled before acting? Use the below code.

Wondering what are the 2 arguments for SetAllowTSConnections function? The first one represents AllowTSConnections(0 – disable, 1 – enable) and the second one represents ModifyFirewallException (0 – don’t modify firewall rules, 1 – modify firewall rules). You can read more about it at https://docs.microsoft.com/en-us/windows/win32/termserv/win32-terminalservicesetting-setallowtsconnections

Hope this article is helpful for you. Feel free to write in the comments section if you have any questions.

Show more