前言:在Windows操作系统中,如何使用脚本简单快速杀端口:
1.在桌面建立一个txt文件
2.打开txt文件打开并且复制以下代码进文本
@echo off & setlocal EnableDelayedExpansion
title kill_port
set /p port=please input port (0~65535):
set pid=0
for /f "tokens=2,5" %%b in ('netstat -ano ^| findstr ":%port%"') do (
set temp=%%b
for /f "usebackq delims=: tokens=1,2" %%i in (`set temp`) do (
if %%j==%port% (
taskkill /f /pid %%c
set pid=%%c
echo portName [ %port% ] had been killed
) else (
echo This port [ %port% ] is not used by this machine
)
)
)
if !pid!==0 (
echo portName [ %port% ] is not used
)
echo complete operations
pause
3.将txt文件的后缀 .txt 改为 .bat
4.双击以上建立的的bat文件 ,并且输入被占的端口号,按一下回车,如果被占就会杀死成功,没有则提示没有占用



