1、定位注册表,[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal ServerWds dpwdTds cp],右侧修改PortNumber的值,选择十进制,将默认的3389端口号更改为其他的希望的端口号,如:56996;
2、再次定位注册表,[HKEY_LOCAL_MACHINESYSTEMCurrentContro1SetControlTenninal ServerWinStationsRDP-Tcp],右侧修改PortNumber的值,选择十进制,将端口号修改为上诉相同的端口号;
3、设置防火墙入站规则,将设置的端口号放行,并关闭默认的3389端口远程规则;
4、重启“Remote Desktop Services”服务或重启计算机后生效。
批处理实例:
@echo off color f0 echo 修改远程桌面3389端口(支持Windows 2003 2008 2008R2 2012 2012R2 7 8 10 ,Windwos 7及以上系统请以管理员身份运行) echo 自动添加防火墙规则 echo %date% %time% echo ARK set /p c= 请输入新的端口: if "%c%"=="" goto end goto edit :edit netsh advfirewall firewall add rule name="Remote PortNumber" dir=in action=allow protocol=TCP localport="%c%" netsh advfirewall firewall add rule name="Remote PortNumber" dir=in action=allow protocol=TCP localport="%c%" reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal ServerWds dpwdTds cp" /v "PortNumber" /t REG_DWORD /d"%c%" /f reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp" /v "PortNumber" /t REG_DWORD/d "%c%" /f net stop TermService net start TermService echo 修改成功! exit :end echo 修改失败 pause