windows: 修复有时重启 rdp 服务时死循环

This commit is contained in:
bin456789 2025-01-06 22:45:33 +08:00
parent 82b3d7053b
commit 4ed62d849f
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -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
)