Find the PID of a process that uses a port on Windows

前端 未结 7 1219
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 16:58

My service crash on startup with the classic:

java.rmi.server.ExportException: Listen failed on port: 9999

How can I find the process for k

7条回答
  •  执念已碎
    2020-11-30 17:35

    Command:

    netstat -aon | findstr 4723
    

    Output:

    TCP    0.0.0.0:4723           0.0.0.0:0                LISTENING       10396
    

    Now cut the process ID, "10396", using the for command in Windows.

    Command:

    for /f "tokens=5" %a in ('netstat -aon ^| findstr 4723') do @echo %~nxa
    

    Output:

    10396

    If you want to cut the 4th number of the value means "LISTENING" then command in Windows.

    Command:

    for /f "tokens=4" %a in ('netstat -aon ^| findstr 4723') do @echo %~nxa
    

    Output:

    LISTENING

提交回复
热议问题