change_rdsport_CN.bat:
@echo off
color f0
echo 修改远程桌面3389端口(支持Windows2003, 2008, 2008R2, 2012, 2012R2, 7, 8, 10)
echo 自动添加防火墙规则
set /p c=请输入新的端口:
if "%c%"=="" goto end
:edit
netsh advfirewall firewall add rule name="Remote PortNumber" dir=in action=allow protocol=TCP localport="%c%"
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v PortNumber /t REG_DWORD /d %c% /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t REG_DWORD /d %c% /f
echo 修改成功
echo 重启后生效,按任意键重启
pause
shutdown /r /t 0
:end
echo 修改失败
pause
change_rdsport_EN:
@echo off
color f0
echo Modify Remote Desktop port 3389 (supports Windows 2003, 2008, 2008R2, 2012, 2012R2, 7, 8, 10)
echo Automatically add firewall rule
set /p c=Please enter the new port:
if "%c%"=="" goto end
:edit
netsh advfirewall firewall add rule name="Remote PortNumber" dir=in action=allow protocol=TCP localport="%c%"
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v PortNumber /t REG_DWORD /d %c% /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t REG_DWORD /d %c% /f
echo Modification successful
echo Takes effect after restart, press any key to restart
pause
shutdown /r /t 0
:end
echo Modification failed
pause
标签:Control,pause,Windows,端口,c%,echo,add,PortNumber,远程桌面
From: https://www.cnblogs.com/wanghongwei-dev/p/18363403