How to use DAT batch file to close a port corresponding program-windows automation command

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.