@echo off
@echo [Remote Desktop port modifier V1.0 update Time 2015/06/10]
TITLE Remote Desktop Port modification Program
Cls
MODE con:cols=68 lines=20
:: The mode statement is the width and height of the set form
SetLocal enabledelayedexpansion
set/p d= "Please enter a new Remote Desktop port:"
Echo will modify the remote Desktop port to [%d%], so be sure to keep that port number in mind.
echo if enabled [System Firewall]--[IPSEC policy]--[TCP/IP Filter] or
echo Other protection software allows the [%d%] port to pass. Otherwise, there will be a problem.
Echo Press any key to continue operation ...
Pause>nul
Set Str=0123456789abcdef
: Loop
set/a y=%d%%%16
set/a D=%D%%/16
Set y=! str:~%y%,1!
Set e=%y%%e%
If%d% geq 1 goto Loop
Echo------------------------------------------------------
Echo is creating the registry file.
Ping-n 2 127.0.1>nul
echo Windows Registry Editor Version 5.00> C:\Remote.reg
echo [hkey_local_machine\system\currentcontrolset\control\terminal server\wds\rdpwd\tds\tcp]>> c \ Remote.reg
echo "PortNumber" =dword:0000%e%>> C:\Remote.reg
echo [hkey_local_machine\system\currentcontrolset\control\terminal server\winstations\rdp-tcp]>> c \ Remote.reg
echo "PortNumber" =dword:0000%e%>> C:\Remote.reg
ECHO is importing the registry file to change the system default settings.
Ping-n 2 127.0.1>nul
REGEDIT/S C:\Remote.reg
del c:\Remote.reg && echo temp file has been deleted.
Ping-n 2 127.0.1>nul
Echo------------------------------------------------------
Echo again reminds you that the port is open.
The echo port has been modified and will not take effect until the server is restarted.
Echo Press any key to exit ...
Pause>nul
Remote Desktop port Modification batch processing