I have no previous batch scripting knowledge. So the question could sound a bit silly. My target is to kill a process listening on a specific port.
I will pass the port number in the batch script argument.
@echo off
netstat -ano | findstr %1
This returns as follow:-
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 23708
TCP [::]:8080 [::]:0 LISTENING 23708
So if do it in the same script as :
taskkill /pid 23708 /F
It should kill the process. I don't know how to get the pid list in an array. How do I do it?