In Windows what can look for port 8080 and try to kill the process it is using through a .BAT file?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s a command to get you started:
When you’re confident in your batch file, remove
@ECHO.Note that you might need to change this slightly for different OS’s. For example, on Windows 7 you might need
tokens=5instead oftokens=4.How this works
This lets you execute
command, and loop over its output. Each line will be stuffed into%variable, and can be expanded out inotherCommandas many times as you like, wherever you like.%variablein actual use can only have a single-letter name, e.g.%V.This lets you split up each line by whitespace, and take the 4th chunk in that line, and stuffs it into
%variable(in our case,%%P).delimslooks empty, but that extra space is actually significant.Just run it and find out. According to the command line help, it “Displays all connections and listening ports.”, “Displays addresses and port numbers in numerical form.”, and “Displays the owning process ID associated with each connection.”. I just used these options since someone else suggested it, and it happened to work 🙂
This takes the output of the first command or program (
netstat) and passes it onto a second command program (findstr). If you were using this directly on the command line, instead of inside a command string, you would use|instead of^|.This filters any output that is passed into it, returning only lines that contain
:8080.This kills a running task, using the process ID.
This is required in batch files. If you did this on the command prompt, you would use
%Pinstead.