Ai_GirlFriend/清理端口.bat
2026-02-04 19:26:08 +08:00

88 lines
2.1 KiB
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
chcp 65001 >nul
title 清理端口 30100 和 30101
echo.
echo ╔════════════════════════════════════╗
echo ║ 清理端口 30100 和 30101 ║
echo ╚════════════════════════════════════╝
echo.
REM ==========================================
REM 清理端口 30100
REM ==========================================
echo [清理] 正在检查端口 30100...
echo.
set FOUND_30100=0
for /f "tokens=5" %%a in ('netstat -ano ^| findstr :30100 2^>nul') do (
set FOUND_30100=1
echo [终止] 进程 PID: %%a
taskkill /F /PID %%a >nul 2>&1
if errorlevel 1 (
echo [警告] 无法终止进程 %%a
) else (
echo [成功] 已终止进程 %%a
)
)
if %FOUND_30100%==0 (
echo [信息] 端口 30100 未被占用
)
echo.
REM ==========================================
REM 清理端口 30101
REM ==========================================
echo [清理] 正在检查端口 30101...
echo.
set FOUND_30101=0
for /f "tokens=5" %%a in ('netstat -ano ^| findstr :30101 2^>nul') do (
set FOUND_30101=1
echo [终止] 进程 PID: %%a
taskkill /F /PID %%a >nul 2>&1
if errorlevel 1 (
echo [警告] 无法终止进程 %%a
) else (
echo [成功] 已终止进程 %%a
)
)
if %FOUND_30101%==0 (
echo [信息] 端口 30101 未被占用
)
echo.
echo ────────────────────────────────────
echo.
echo [完成] 端口清理完成!
echo.
REM 等待端口完全释放
echo [等待] 等待端口完全释放3秒...
timeout /t 3 >nul
echo.
echo [验证] 验证端口状态...
echo.
netstat -ano | findstr :30100
if errorlevel 1 (
echo [✓] 端口 30100 已释放
) else (
echo [✗] 端口 30100 仍被占用
)
netstat -ano | findstr :30101
if errorlevel 1 (
echo [✓] 端口 30101 已释放
) else (
echo [✗] 端口 30101 仍被占用
)
echo.
echo 按任意键退出...
pause >nul