From 4ed62d849f2d009bb1eed15aa8a7d1ef386c87cb Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 6 Jan 2025 22:45:33 +0800 Subject: [PATCH] =?UTF-8?q?windows:=20=E4=BF=AE=E5=A4=8D=E6=9C=89=E6=97=B6?= =?UTF-8?q?=E9=87=8D=E5=90=AF=20rdp=20=E6=9C=8D=E5=8A=A1=E6=97=B6=E6=AD=BB?= =?UTF-8?q?=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- windows-change-rdp-port.bat | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/windows-change-rdp-port.bat b/windows-change-rdp-port.bat index bf4a0b6..2cfc0e1 100644 --- a/windows-change-rdp-port.bat +++ b/windows-change-rdp-port.bat @@ -47,9 +47,17 @@ rem TermService 运行后,UmRdpService 会自动运行 rem 如果刚好系统在启动 rdp 服务,则会失败,因此要用 goto 循环 rem The Remote Desktop Services service could not be stopped. +rem 有的机器会死循环,开机 logo 不断转圈 +rem 通过 netstat netstat -ano 可以看到端口已修改成功,但rdp服务不断重启 (pid一直改变) +rem 因此限定重试次数避免死循环 + +set retryCount=5 + :restartRDP +if %retryCount% LEQ 0 goto :del net stop TermService /y && net start TermService || ( - timeout 5 + set /a retryCount-=1 + timeout 10 goto :restartRDP )