You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.7 KiB
Batchfile

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

@echo off
setlocal enabledelayedexpansion
rem ====================================================
rem 处理端口 8010
rem ====================================================
echo 查找并结束占用 8010 端口的进程…
for /f "tokens=5" %%a in ('netstat -ano ^| findstr /R /C:":8010"') do (
rem 确保 PID 不是 0
if %%a neq 0 (
echo 找到 PID=%%a占用 8010 端口
echo 正在结束进程 %%a …
taskkill /F /PID %%a >nul 2>&1
if ERRORLEVEL 0 (
echo 成功结束进程 %%a
) else (
echo 无法结束进程 %%a可能已结束或权限不足
)
)
)
echo.
rem ====================================================
rem 处理端口 9880支持 IPv4 和 IPv6
rem ====================================================
echo 查找并结束占用 9880 端口的进程…
for /f "tokens=5" %%b in ('
netstat -ano ^| findstr /R /C:":9880 "
') do (
rem 确保 PID 不是 0
if %%b neq 0 (
echo 找到 PID=%%b占用 9880 端口
echo 正在结束进程 %%b …
taskkill /F /PID %%b >nul 2>&1
if %ERRORLEVEL% equ 0 (
echo 成功结束进程 %%b
) else (
echo 无法结束进程 %%b可能已结束或权限不足
)
)
)
echo.
rem ====================================================
rem 处理进程名称 chat.exe
rem ====================================================
echo 查找并结束所有名为 chat.exe 的进程…
for /f "tokens=2" %%c in ('tasklist ^| findstr /R /C:"chat.exe"') do (
rem 确保 PID 不是 0
if %%c neq 0 (
echo 找到 PID=%%c正在结束进程 chat.exe …
taskkill /F /PID %%c >nul 2>&1
if ERRORLEVEL 0 (
echo 成功结束进程 %%c
) else (
echo 无法结束进程 %%c可能已结束或权限不足
)
)
)
echo.
rem 脚本执行完毕后退出命令行窗口
exit