Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using netstat -a -o -n I can get the list of ports and PID

then I need to go to task manager and add the PID and see who is it. (pretty frustrating)

enter image description here

I was wonder if there is a CMD command which does it all ( using find , for , powershell)

so that I could get the process name

share|improve this question
netstat -b as admin, e.g. netstat -abon. And the name of the exe is below – barlop May 13 at 5:03
up vote 18 down vote accepted


Use the -b parameter:

  -b            Displays the executable involved in creating each connection or
                listening port. In some cases well-known executables host
                multiple independent components, and in these cases the
                sequence of components involved in creating the connection
                or listening port is displayed. In this case the executable
                name is in [] at the bottom, on top is the component it called,
                and so forth until TCP/IP was reached. Note that this option
                can be time-consuming and will fail unless you have sufficient

Note The netstat -b command will fail unless run from an elevated command prompt.


Filter the process list and find the PID you're interested in:

tasklist | findstr /c:"PID"  

Alternate solution

You can use Tcpvcon.exe instead. No admin rights required.

Tcpvcon usage is similar to that of the built-in Windows netstat utility.

Usage: tcpvcon [-a] [-c] [-n] [process name or PID]

 -a Show all endpoints (default is to show established TCP connections).
 -c Print output as CSV.
 -n Don't resolve addresses.
share|improve this answer
you're the man. – Royi Namir Jan 26 '14 at 19:14
good answer, just commenting that I think it's amusing how the ms /? documentation even says "this option can be time-consuming" ! and it's purely a stupidity of windows that it is time consuming. Linux's netstat does its executable name showing fast. And also linux's executable name showing doesn't require root/admin privileges – barlop May 13 at 5:05

I think you are looking for TCPView from SysInternals.

share|improve this answer
I was wonder if there is a CMD command which does it all – Royi Namir Jan 26 '14 at 16:13
Keep going - There is a command-line component of TCPView.. – Leptonator Jan 26 '14 at 16:14
oh ok. thought maybe someone already done it using for,find etc. – Royi Namir Jan 26 '14 at 16:15
It should not be too hard to do.. I would bet has something on it. Per the TCPView Page - "The TCPView download includes Tcpvcon, a command-line version with the same functionality." – Leptonator Jan 26 '14 at 16:16
Very good tool suite.. if it wasn't for msys and sis I'd be using a nix box. :) – Eddie B Aug 7 '15 at 18:38

If you're fond of using PS, you can fork this code (note: it's super-basic)

$nets = netstat -ano|select-string LISTENING;
foreach ($n in $nets)
# make split easier PLUS make it a string instead of a match object
    $p = $n -replace ' +',' ';
# make it an array
    $nar = $p.Split(' ');
# pick last item...
    $pname = $(Get-Process -id $nar[-1]).ProcessName;
# print the modified line with processname instead of PID
    $n -replace "$($nar[-1])","$($ppath) $($pname)";

Note that you can try Path instead of ProcessName to get a full executable path - won't work with system services though. Also, you may want to append the ProcessName to the end of the line instead of replacing the PID value - enjoy it ;)

share|improve this answer

Here is an example for windows using FOR to parse netstat output then DO tasklist with /fi filter on pid to show process name.

The last find is to remove tasklist headers.

FOR /F "usebackq tokens=5 delims= " %i IN (`netstat -ano ^|find "443"`) DO @tasklist /fi "pid eq %i" | find "%i"

prints records output like

tomcat8.exe.x64               4240 Services                   0    931,864 K

Additional fields from netstat can be added by adding tokens.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.