How to change Terminal Services Port Via the Command line

Say we want to make Terminal Services listen on port 2222


Use a decimal to hex editor for your port choosing.  I am using 2222.  The hexadecimal value is 8ae for 2222.

You can also drop into powershell and use the Convert command at the command  prompt by typing


>[Convert]::ToString(2222, 16)

This will display 8ae.

C:\Windows\system32>reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control
\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t REG_DWORD /d 0x8ae


You will need to restart the terminal services so you can do this via command line as well.


C:\Windows\system32> sc stop TermService


Buggers it fails and says this process is used by another process.


So lets tackle this from a different angle


use this command


>wmic PROCESS GET Caption, Commandline, ProcessID, ParentProcessID


okay now look for


svchost.exe                      C:\Windows\system32\svchost.exe -k NetworkService


Find the ProcessID for that service.


now kill that service


> taskkill /pid 1104 /F




>  sc start TermService


> netstat -na


now it show my Terminal Service running under 2222