I am looking for a simple batch script that kills a process which listens to a certain ip and to a certain port. If there are less than 10 connections to this process, then it should be killed. If there are more than 10 established connections, the process should not be killed. (it can count the number of lines from -ano output and if there are less than 10 lines it should kill it)
I am currently using a simillar script but for a different task: Batch file that kills a certain process but instead of increasing it should decrease connections number and kills the process if there are less than x connections to that ip:port. Connection state in this case doesn't matter, it just has to count the number of connections only.