DOS下cmd查询端口和PID号

1.开始 -> 运行 -> cmd 2. 查找端口的PID: netstat -a -o 3. 强行关闭: ntsd -c q -p PID(查询出来的PID号码) 或者进入任务管理器 -> 查看 -> 选择列 -> 将PID选中 -> 进程(找到查询到的PID) -> 结束进程

 

CTRL+C可让运行中的cmd命令停止

 

 

 

第一步: Tasklist/SVC 列出所有进程,系统服务及其对应的PID值!

 

  而终端所对应的服务名为:TermService

C:/Documents and Settings/Administrator>Tasklist/SVC

--------------------------------------------------------------------

进程名                                   PID 服务
================   ==========

System Idle Process            0 暂缺
System                         4 暂缺
smss.exe                     480 暂缺
csrss.exe                    536 暂缺
winlogon.exe                 560 暂缺
SERVICES.EXE                 604 Eventlog, PlugPlay
LSASS.EXE                    616 PolicyAgent, ProtectedStorage, SamSs
SVCHOST.EXE                  768 DcomLaunch, TermService
SVCHOST.EXE                  820 RpcSs
SVCHOST.EXE                  956 Dnscache
SVCHOST.EXE                 1068 LmHosts, RemoteRegistry, SSDPSRV
ZhuDongFangYu.exe           1104 ZhuDongFangYu
aswUpdSv.exe                1180 aswUpdSv
ashServ.exe                 1236 avast! Antivirus
spoolsv.exe                 1480 Spooler
SVCHOST.EXE                 1960 WebClient
WVSScheduler.exe            1988 AcuWVSSchedulerv6
httpd.exe                   2008 Apache2.2
SQLSERVR.EXE                 168 MSSQL$SQLEXPRESS
httpd.exe                    252 暂缺
sqlservr.exe                1556 MSSQLSERVER
EXPLORER.EXE                1588 暂缺
mysqld-nt.exe               1668 MySQL
sqlwriter.exe               1840 SQLWriter
SVCHOST.EXE                 1864 stisvc
wdfmgr.exe                  1740 UMWdf
ashDisp.exe                 2392 暂缺
360tray.exe                 2456 暂缺
GoogleQuickSearchBox.exe    2496 暂缺
ashMaiSv.exe                2540 avast! Mail Scanner
ctfmon.exe                  2552 暂缺
GoogleToolbarNotifier.exe   2568 暂缺
ashWebSv.exe                2604 avast! Web Scanner
ApacheMonitor.exe           2696 暂缺
sqlmangr.exe                2720 暂缺
ALG.EXE                     3056 ALG
qq.exe                      3588 暂缺
wvs.exe                     3268 暂缺
IEXPLORE.EXE                2996 暂缺
NOTEPAD.EXE                 2036 暂缺
cmd.exe                     1968 暂缺

--------------------------------------------------------------------

第二步:用netstat -ano命令,列出所有端口对应的PID值!

  找到PID值所对应的端口

 同样,找Serv-U,radmin,等端口都适用!

C:/Documents and Settings/Administrator>netstat -ano

--------------------------------------------------------------------

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       2008
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       820
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:1433           0.0.0.0:0              LISTENING       1556
  TCP    0.0.0.0:3306           0.0.0.0:0              LISTENING       1668
  TCP    127.0.0.1:1030         0.0.0.0:0              LISTENING       3056
  TCP    127.0.0.1:1634         127.0.0.1:12080        ESTABLISHED     2996
  TCP    127.0.0.1:3967         127.0.0.1:12080        ESTABLISHED     2996
  TCP    127.0.0.1:5488         127.0.0.1:12080        ESTABLISHED     2996
  TCP    127.0.0.1:5496         127.0.0.1:12080        ESTABLISHED     2996
  TCP    127.0.0.1:5508         127.0.0.1:12080        ESTABLISHED     2996
  TCP    127.0.0.1:5562         127.0.0.1:12080        ESTABLISHED     2996
  TCP    127.0.0.1:12025        0.0.0.0:0              LISTENING       2540
  TCP    127.0.0.1:12080        0.0.0.0:0              LISTENING       2604
  TCP    127.0.0.1:12080        127.0.0.1:1634         ESTABLISHED     2604
  TCP    127.0.0.1:12080        127.0.0.1:3967         ESTABLISHED     2604
  TCP    127.0.0.1:12080        127.0.0.1:5488         ESTABLISHED     2604
  TCP    127.0.0.1:12080        127.0.0.1:5552         ESTABLISHED     2604
  TCP    127.0.0.1:12080        127.0.0.1:5555         ESTABLISHED     2604
  TCP    127.0.0.1:12080        127.0.0.1:5562         ESTABLISHED     2604
  TCP    127.0.0.1:12110        0.0.0.0:0              LISTENING       2540
  TCP    127.0.0.1:12119        0.0.0.0:0              LISTENING       2540
  TCP    127.0.0.1:12143        0.0.0.0:0              LISTENING       2540
  TCP    192.168.1.100:139      0.0.0.0:0              LISTENING       4
  TCP    192.168.1.100:1055     119.147.18.89:443      CLOSE_WAIT      3588
  TCP    192.168.1.100:1635     58.63.237.107:80       ESTABLISHED     2604
  TCP    192.168.1.100:2713     119.147.18.89:443      CLOSE_WAIT      3588
  TCP    192.168.1.100:5511     218.30.115.246:80      ESTABLISHED     2604
  TCP    192.168.1.100:5515     218.30.115.233:80      CLOSE_WAIT      2604
  TCP    192.168.1.100:5652     202.91.240.35:80       ESTABLISHED     3268
  TCP    192.168.1.100:5653     202.91.240.35:80       ESTABLISHED     3268
  TCP    192.168.1.100:5659     202.91.240.35:1414     SYN_SENT        3268
  TCP    192.168.1.100:5660     202.91.240.35:1415     SYN_SENT        3268
  TCP    192.168.1.100:5661     202.91.240.35:1416     SYN_SENT        3268
  TCP    192.168.1.100:5662     202.91.240.35:1417     SYN_SENT        3268
  TCP    192.168.1.100:5663     202.91.240.35:1418     SYN_SENT        3268
  TCP    192.168.1.100:5664     202.91.240.35:80       ESTABLISHED     3268
  TCP    192.168.1.100:5665     202.91.240.35:80       ESTABLISHED     3268
  TCP    192.168.1.100:5666     202.91.240.35:80       ESTABLISHED     3268
  TCP    192.168.1.100:5667     202.91.240.35:80       ESTABLISHED     3268
  UDP    0.0.0.0:445            *:*                                    4
  UDP    0.0.0.0:500            *:*                                    616
  UDP    0.0.0.0:2709           *:*                                    3588
  UDP    0.0.0.0:4000           *:*                                    3588
  UDP    0.0.0.0:4500           *:*                                    616
  UDP    0.0.0.0:6003           *:*                                    3588
  UDP    127.0.0.1:123          *:*                                    888
  UDP    127.0.0.1:1043         *:*                                    3588
  UDP    127.0.0.1:1070         *:*                                    2456

你可能感兴趣的:(apache,tcp,cmd,dos,System,任务)