更改windows 远程桌面端口 和 解决画面卡顿或卡死问题

尝试用远程桌面,跨网域公网连接。还遇到了连上后卡顿,画面卡死,还不如向日葵快。。。结果发现是公网的udp丢包严重,而这个远程桌面又会自动udp连接。得手动改为tcp连接,画面才变得流畅。。。

一个脚本解决,需要 powershell 管理员权限

ps1 复制代码
# 想要新远程桌面端口,默认是3389,我设定为16251
$portvalue = 16251

# 设定注册表,修改远程桌面端口号
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue 

# 删除之前定的同名防火墙规则,如果有的话
Remove-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In'
Remove-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In'

# 设定防火墙 允许远程桌面使用 新的端口连接
# 必须设定防火墙允许规则,不然新端口连不上。当然关掉防火墙也可行。
New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Any' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvalue 
New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Any' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue

# 设定注册表,让远程桌面只使用TCP连接,因为公网的UDP丢包率很高,会导致画面卡顿或卡死。
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -name "SelectTransport" -Value 1

参考资料:

更改计算机上的远程桌面的侦听端口

https://learn.microsoft.com/zh-cn/windows-server/remote/remote-desktop-services/clients/change-listening-port

Windows远程桌面连接经常卡死解决办法

https://blog.csdn.net/spidernet/article/details/136008670

选择 RDP 传输协议

https://admx.help/?Category=Windows_10_2016\&Policy=Microsoft.Policies.TerminalServer::TS_SELECT_TRANSPORT\&Language=zh-cn

求助\] 用win11 24H2 远程桌面卡还容易断线 https://bbs.pcbeta.com/viewthread-2032711-1-1.html

相关推荐
x-cmd3 分钟前
[250416] GitHub Action 新升级,支持 Windows on Arm
arm开发·windows·github·github action
.m5 小时前
5款电脑健康状况监测软件
windows
MobiCetus11 小时前
Linux Kernel 7
linux·运维·服务器·windows·ubuntu·centos·gnu
pursue.dreams12 小时前
Windows 下 MongoDB ZIP 版本安装指南
数据库·windows·mongodb
会飞的土拨鼠呀16 小时前
SP B\nRebuild Priorit> 如何用python去掉\n
开发语言·windows·python
骐骥118 小时前
Notepad++中将文档格式从Windows(CR LF)转换为Unix(LF)
windows·notepad++·unix·格式·换行符
Awesome Baron1 天前
jupyter中切换Anaconda虚拟环境
windows·python·jupyter
庸子1 天前
Active Directory域服务管理与高级应用技术白皮书
运维·服务器·网络·windows·ad
21号 11 天前
21.C++11
windows
fly spider1 天前
一站式Windows下Docker开启MySQL并链接本地Navicat(附乱码解决方案)
windows·mysql·docker·乱码解决