How do I close a port corresponding program with DAT batch file?
Most of the online find is manual operation, the first step to identify the port, the second step in accordance with the previous step of the port to manually shut down the process. But my needs are not so, I need to fully automatic processing. Used to shut down the Dubbo service process in a Windows environment. If you have a Linux environment, it doesn't have to be that hard.
Find the majority of days, finally in Baidu know to get reference case (perhaps I use the keyword is not correct), and successfully tested, thanks to the relevant contributors.
Answer one:
for/F "tokens=1-5 delims="%%a in (' "Netstat-ano|findstr" ^: Specify port number do taskkill/pid%%e
Answer two:
@echo off set port=1234 for do taskkill/pid%%m
My own trial of successful script is as follows:
@echo off set port=20812 for does ( echo Use the port%port% / PID%%m)
Reference Address: Http://zhidao.baidu.com/link?url= Wga-tp8nkqfi2bla1brn5zyjz1tzzs3sr1qcps0ts2nhbiuee9byfcno31imk337dhvoand05ezyl0nmf0hopa
How to use DAT batch file to close a port corresponding program-windows automation command