reinstall/windows-frpc-workaround.bat
2025-04-28 23:18:27 +08:00

19 lines
727 B
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
mode con cp select=437 >nul
rem 如果找到 LOCAL SERVICE 运行的 frpc则结束 SYSTEM 运行的 frpc
rem 如果没找到 frpc则运行 frpc本脚本是用 SYSTEM 运行,好像无法 runas "NT AUTHORITY\LOCAL SERVICE"
rem tasklist 返回值始终为 0因此需要用 findstr
:loop
tasklist /FI "IMAGENAME eq frpc.exe" /FI "USERNAME eq NT AUTHORITY\LOCAL SERVICE" | findstr /I "frpc.exe" && goto :kill_system_frpc
tasklist /FI "IMAGENAME eq frpc.exe" | findstr /I "frpc.exe" || start %SystemDrive%\frpc\frpc.exe -c %SystemDrive%\frpc\frpc.toml
timeout 5
goto :loop
:kill_system_frpc
taskkill /F /T /FI "IMAGENAME eq frpc.exe" /FI "USERNAME eq NT AUTHORITY\SYSTEM"
del "%~f0"