![解決](https://rvso.com/image/1395286/%E8%A7%A3%E6%B1%BA.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
以下は、Windows を使用して出力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
これを使ってみてください...
タイムスタンプ付きのプロセス名 :) ワンライナーで... スクリプトは不要で、高速かつ簡単です...
SYN_SENTパラメータをESTABLISHEDまたはLISTENINGに変更できます。
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