优化RDP的连接质量
优化目的:
- 可以修改默认远程桌面端口
- 修改默认显示帧数由30改到60
- 修改默认的udp连接方式为udp(如果是远程vps,udp被qos的情况下就不要开,但是udp的话高帧率会更流程)
脚本一:流畅度优化,修改帧数和端口
@echo off
color f0
echo Create By gtsy.ml
set /p s= RDP优化输入1,清理输入2:
if "%s%"=="1" goto init
if "%s%"=="2" goto clean
if "%s%"=="" goto end
goto end
:init
set /p c= 请输入新的端口:
if "%c%"=="" goto end
goto edit
:edit
reg add "HKEY_LOCAL_MACHINE\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 自动添加防火墙规则
netsh advfirewall firewall add rule name="Remote Desktop TCP-In" dir=in action=allow protocol=TCP localport="%c%"
netsh advfirewall firewall add rule name="Remote Desktop UDP-In" dir=in action=allow protocol=UDP localport="%c%"
echo 设置显示帧数60
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations" /v "DWMFRAMEINTERVAL" /t REG_DWORD /d 15 /f
echo 启用远程桌面服务
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
wmic RDTOGGLE WHERE ServerName='%COMPUTERNAME%' call SetAllowTSConnections 1
echo 即将重启远程桌面服务,连接会断开,之后请使用新端口%c%连接!
echo 云服务器需要在后台防火墙添加新端口%c%的tcp,udp协议放行规则!
echo 按任意键开始重启服务!
pause
net stop TermService /y
net start TermService
echo 优化完成,按任意键退出!
pause
exit
:clean
echo 还原远程桌面默认端口(3389端口)
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v "PortNumber" /t REG_DWORD /d 3389 /f
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v "PortNumber" /t REG_DWORD /d 3389 /f
echo 删除远程桌面自定义防火墙规则
netsh advfirewall firewall delete rule name="Remote Desktop TCP-In"
netsh advfirewall firewall delete rule name="Remote Desktop UDP-In"
echo 还原默认显示帧数30
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations" /v "DWMFRAMEINTERVAL" /f
::echo 停用远程桌面服务
::reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 1 /f
::wmic RDTOGGLE WHERE ServerName='%COMPUTERNAME%' call SetAllowTSConnections 0
::echo 关闭远程桌面服务
::net stop TermService /y
echo 清理完成,按任意键退出!
pause
exit
:end
echo 未作修改!
pause
更改连接方式为udp
@echo off
color f0
echo Create By gtsy.ml
echo 跨境线路或运营商对udp进行QoS可能会导致udp模式不稳定.
echo 这种情况下请不要开启udp模式.
set /p s= 开启远程桌面服务udp模式输出1,关闭输入2:
if "%s%"=="1" goto init
if "%s%"=="2" goto clean
if "%s%"=="" goto end
goto end
:init
echo 启用远程桌面服务udp模式
reg add "HKEY_LOCAL_MACHINE\software\policies\microsoft\windows nt\Terminal Services\Client" /v fClientDisableUDP /t REG_DWORD /d 0 /f
echo udp模式已启用,按任意键退出!
pause
exit
:clean
echo 停用远程桌面服务udp模式
reg add "HKEY_LOCAL_MACHINE\software\policies\microsoft\windows nt\Terminal Services\Client" /v fClientDisableUDP /t REG_DWORD /d 1 /f
echo udp模式已停用,按任意键退出!
pause
exit
:end
echo 未作修改!
pause