Skip to content

Commit

Permalink
windows: 修复有时重启 rdp 服务时死循环
Browse files Browse the repository at this point in the history
  • Loading branch information
bin456789 committed Jan 6, 2025
1 parent 82b3d70 commit 4ed62d8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion windows-change-rdp-port.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down

0 comments on commit 4ed62d8

Please sign in to comment.