![해결책](https://rvso.com/image/1395286/%ED%95%B4%EA%B2%B0%EC%B1%85.png)
를 사용하면 netstat -a -o -n
포트 및 PID 목록을 얻을 수 있습니다.
그런 다음 작업 관리자로 가서 PID를 추가하고 누구인지 확인해야 합니다. (꽤 답답함)
모든 작업을 수행하는 CMD 명령이 있는지 궁금합니다( find
, for
, 사용 powershell
).
프로세스 이름을 얻을 수 있도록
답변1
해결책
다음 매개변수를 사용하세요 -b
.
-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
permissions.
메모netstat -b
관리자 권한 명령 프롬프트에서 실행하지 않으면 명령이 실패합니다 .
해결 방법
프로세스 목록을 필터링하고 관심 있는 PID를 찾으세요.
tasklist | findstr /c:"PID"
대체 솔루션
대신 사용할 수 있습니다 Tcpvcon.exe
. 관리자 권한이 필요하지 않습니다.
Tcpvcon사용법은 내장된 Windows
netstat
유틸리티의 사용법과 유사합니다.
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.
답변2
찾고 계시는 것 같아요TCP보기SysInternals에서.
답변3
다음은 출력을 FOR
구문 분석하는 데 사용하고 프로세스 이름을 표시하기 위해 pid에 필터를 사용하는 창의 예입니다 .netstat
DO
tasklist
/fi
마지막 발견은 tasklist
헤더를 제거하는 것입니다.
FOR /F "usebackq tokens=5 delims= " %i IN (`netstat -ano ^|find "443"`) DO @tasklist /fi "pid eq %i" | find "%i"
다음과 같은 레코드 출력을 인쇄합니다.
tomcat8.exe.x64 4240 Services 0 931,864 K
netstat
토큰을 추가하여 추가 필드를 추가할 수 있습니다.
답변4
이것을 사용해보십시오 ...
타임 스탬프가 포함된 프로세스 이름 :) oneliner에서... 빠르고 쉽게 스크립팅할 필요가 없습니다...
ESTABLISHED 또는 LISTENING으로 SYN_SENT 매개변수를 변경할 수 있습니다.
filter timestamp {"$(Get-Date -Format G): $_"};netstat -abno 1 | Select-String -Context 0,1 -Pattern LISTENING|timestamp
filter timestamp {"$(Get-Date -Format G): $_"};netstat -abno 1 | Select-String -Context 0,1 -Pattern SYN_SENT|timestamp