The Windows netstat command can tell you the association of network connection and executable file, i.e. which application (program) is using the network connection port.
To get this information, you need to run this command
Obviously, it gives what we want, but the output format is not easy to read or filter. So, let’s fine tune its output withGNU awk and grep for Windows.
Now, install that two GNU programs, then copy and paste these 3 lines to elevated Command Prompt window and press ENTER to run:
To get this information, you need to run this command
netstat -anqb in an elevated Command Prompt window(the -b option requires elevated privilege). Obviously, it gives what we want, but the output format is not easy to read or filter. So, let’s fine tune its output withGNU awk and grep for Windows.
Now, install that two GNU programs, then copy and paste these 3 lines to elevated Command Prompt window and press ENTER to run:
netstat -anqb |^
awk "{if ($1 ~/TCP|UDP/)printf \"\n%s\", $0;else printf \" %s\",$0}" |^
egrep -vw "LISTENING|TIME_WAIT|CLOSE_WAIT"
The netstat output should look better now, similar to this one:
NOTE: If you want to save that 3 lines in batch file (e.g. ListConn.cmd script file), you need to change each of the % character to %%, i.e.:
netstat -anqb |^
awk "{if ($1 ~/TCP|UDP/)printf \"\n%%s\", $0;else printf \" %%s\",$0}" |^
egrep -vw "LISTENING|TIME_WAIT|CLOSE_WAIT"
To explore Windows netstat command option, execute this command
netstat /?.
0 comments:
Post a Comment