批处理修改远程桌面端口号 批处理修改rdp端口
2023-11-22 08:50:19Windows
如何使用批处理一键修改远程桌面端口号?Windows 远程桌面服务默认使用的是 3389 端口,该端口常常被定义为高危端口而被要求关闭。关闭之后若无法使用远程桌面,此时可修改默认的
如何使用批处理一键修改远程桌面端口号?Windows 远程桌面服务默认使用的是 3389 端口,该端口常常被定义为高危端口而被要求关闭。关闭之后若无法使用远程桌面,此时可修改默认的 3389 端口为其它端口。手动修改可能有点麻烦(需操作注册表),可通过下面的 BAT 批处理程序直接完成修改。
批处理修改rdp端口
使用方法:将以下代码复制保存为“一键修改远程桌面端口号.bat”。右击“以管理员身份运行”即可。
@echo off
color 0a
title 修改 Windows 远程桌面端口号 by itmemo.cn
echo.
echo 输入您要更改的远程桌面端口号,范围:1024-65535,不能与其他端口冲突!
echo.
set /p port=请输入端口号:
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v PortNumber /t reg_dword /d %port% /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t reg_dword /d %port% /f
netsh advfirewall firewall set opmode mode = enable
netsh advfirewall firewall set portopening all 80 web enable
netsh advfirewall firewall set portopening all 3389 remote-pre enable
netsh advfirewall firewall set portopening all %port% remote enable
echo.
echo 重新启动远程桌面……
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t reg_dword /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t reg_dword /d 0 /f
echo.
echo 下面开始重新启动电脑以生效,请选择启动方式:
echo 选择1手动重新启动
echo 选择2自动重新启动
set /p select=请您选择 [ 1 或 2 ]:
if "%select%"=="1" goto A
if "%select%"=="2" goto B
pause
exit
:A
echo 退出,请手动重新启动电脑
pause
exit
:B
shutdown -r -t 1
pause
exit
使用以上批处理修改远程桌面端口号,可以节约您的时间,提升办公效率!
相关内容标签
赞一个! ()