Windows操作系统远程桌面端口修改脚本
change_rdsport_CN.bat(支持Windows2003, 2008, 2008R2, 2012, 2012R2, 7, 8, 10)
@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 修改成功
:confirm
set /p restart=重启后生效,是否立即重启? (Y/y确认, 其他键跳过重启):
if /I "%restart%"=="Y" (
shutdown /r /t 0
) else (
echo 已跳过重启
)
:end
pause
change_rdsport_CN.bat(支持Windows Server 2016, 2019, 2022)
@echo off
color f0
echo 修改远程桌面3389端口(支持Windows Server 2016, 2019, 2022)
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 "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t REG_DWORD /d %c% /f
echo 修改成功
:confirm
set /p restart=重启后生效,是否立即重启? (Y/y确认, 其他键跳过重启):
if /I "%restart%"=="Y" (
shutdown /r /t 0
) else (
echo 已跳过重启
)
:end
pause
change_rdsport_EN.bat(supports Windows 2003, 2008, 2008R2, 2012, 2012R2, 7, 8, 10)
@echo off
color f0
echo Modify Remote Desktop Port 3389 (supports Windows 2003, 2008, 2008R2, 2012, 2012R2, 7, 8, 10)
echo Automatically add firewall rules
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
:confirm
set /p restart=Changes will take effect after reboot. Do you want to reboot now? (Y/y to confirm, any other key to skip reboot):
if /I "%restart%"=="Y" (
shutdown /r /t 0
) else (
echo Reboot skipped
)
:end
pause
change_rdsport_EN.bat(supports Windows server 2016, 2019, 2022)
@echo off
color f0
echo Modify Remote Desktop Port 3389 (supports Windows server 2016, 2019, 2022)
echo Automatically add firewall rules
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 "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t REG_DWORD /d %c% /f
echo Modification successful
:confirm
set /p restart=Changes will take effect after reboot. Do you want to reboot now? (Y/y to confirm, any other key to skip reboot):
if /I "%restart%"=="Y" (
shutdown /r /t 0
) else (
echo Reboot skipped
)
:end
pause
作者:wanghongwei
版权声明:本作品遵循<CC BY-NC-ND 4.0>版权协议,商业转载请联系作者获得授权,非商业转载请附上原文出处链接及本声明。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
2023-08-16 Iptables mangle表和raw表应用场景介绍