T
T
Talyan2019-07-02 19:00:13
cmd/bat
Talyan, 2019-07-02 19:00:13

How to kill a process using a specific port in Windows?

Users often hang the process of one of the add-ons for Internet Explorer (KKM ATOL), the process is a tab in the browser. IE sometimes won't terminate a hung process even after closing the entire "browser".
The process is monitored by the team:

netstat -ano | find /I "6220" | find /I "ESTABLISHED"

The result of running this command:
TCP    10.32.0.34:60541       10.32.0.146:6220       ESTABLISHED     3520
, where 3520 is the PID of the process.
How can I modify the console command so that taskkill kills the process with the correct pid?
taskkill /f /im iexplore.exedoing it is not an option, since the whole browser is being killed, not the tab, and users have to log in again in each tab again.
Is it even possible to do this in Windows? If it matters, then users have different Windows: from XP Professional to 10 Professional.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin Tsvetkov, 2019-07-02
@flapflapjack

will give an error, since the input to taskkill does not get the PID, but the whole line from netstat.
The command SETmay truncate the string.
Or in full:
@echo off
for /f "tokens=1 delims==" %%i in ('"netstat -ano | find /I "6220" | find /I "ESTABLISHED" "') do set var=%%i
taskkill /F /PID %var:~-4%

S
Stalker_RED, 2019-07-02
@Stalker_RED

taskkill /F /PID pid_number
https://docs.microsoft.com/en-us/windows-server/ad...
or
taskkill /?

S
Saiputdin Omarov, 2019-07-02
@generalx

sc queryx has a lot to say too

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question