优秀是一种习惯!!!

Bat常用脚本文件合集

2023-11-29

Bat常用脚本文件合集

一、netstat -ano | findstr <端口号> taskkill /F /PID <进程ID> 使用上述两条命令在windows 10系统上强制关闭65425、65450、65401、65400、65500、65430这些端口

可以使用以下的bat文件脚本内容来强制关闭指定端口的进程:

@echo off

set ports=65425 65450 65401 65400 65500 65430

for %%p in (%ports%) do (
   echo Killing processes on port %%p...
   for /f "tokens=5" %%a in ('netstat -ano ^| findstr "%%p"') do (
       echo Taskkill /F /PID %%a
       taskkill /F /PID %%a
   )
)

echo All specified processes have been terminated.

将以上内容保存为一个扩展名为.bat的文件,然后在Windows 10系统上运行该脚本即可。脚本会逐个检测并关闭指定端口的进程。请确保以管理员权限运行该脚本。

二、


标题:Bat常用脚本文件合集
作者:amethystfob
地址:https://newmoon.top/articles/2023/11/28/1701163162490.html

欢迎各路大侠指点留痕: