Enable remote desktop access, using command line

If you need to RDP into a windows box that you have commandline access to, this is for you.


  1. First, permit RDP through the firewall.

    netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
    
    
    
  2. Then, enable terminal services in the registry using the reg command:
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
    
    
    
  3. Done!



To disable Remote Desktop access is just as easy:


  1. First, deny RDP through the firewall.

    netsh advfirewall firewall set rule group="remote desktop" new enable=No
    
    
    
  2. Then, disable terminal services in the registry using the reg command:
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 1 /f
    
    
    
  3. Done!


Please note, you may need to reboot the windows machine for the changes to take effect (though problably not), and this doesn't work on "home" editions of Windows.

No comments:

Post a Comment