i have a problem with application and i want to write a batch script which is be able to close all connections from one IP expect the last.
this is output of netstat. I want to close all connections expect the last one.
10.10.10.10:2299 192.168.10.2:34624 ESTABLISHED
10.10.10.10:2299 192.168.10.2:34761 ESTABLISHED
10.10.10.10:2299 192.168.10.2:34764 ESTABLISHED
10.10.10.10:2299 192.168.10.2:35001 ESTABLISHED
i'm newbie to batch scripting and need help with my code..
set ips=netstat -ano | find "192.168.10." | find "2299"
set closeip
set close port
for %%ip in %ips% do (
don't know what to write here :(
#currports util
#C:\cports\cports.exe /close * * %closeip% %closeport%
thank for your attention!
so recently i used a powershell script.
I used Get-NetTCPConnection
and filter by "CreationTime"
and it worked like a charm!