windows dos 命令

212 阅读1分钟

一、查看端口(文中 [|] 用英文下划线代替)
在windows命令行窗口下执行:

> netstat -aon[|]findstr "8080"  

显示结果:

TCP     127.0.0.1:80         0.0.0.0:0               LISTENING       2448 

端口“8080”被PID(进程号)为2448的进程占用。

查看端口“8080”被哪个应用占用,,继续执行下面命令:

> tasklist[|]findstr "2448" 
notepad.exe                     2016 Console                 0     16,064 K 

二、关闭进程
2.1 按进程号关闭进程

> taskkill /pid 2152  

多个时格式为:

> taskkill /pid 2152 /pid 1284  

2.2 按进程名关闭进程
如要关闭notepad.exe,格式为:

> taskkill /im notepad.exe  

指定多个时格式为:

> taskkill /im notepad.exe /im iexplorer.exe   

如果是要关闭所有的,则使用通配符*,即:

> taskkill /im *.exe  

2.3 有提示的关闭进程

> taskkill /t /im notepad.exe  
> taskkill /t /pid 2152  

这个效果是提示后在使用者确定后关闭,有提示框。

2.4 强行终止进程

> taskkill /f /im notepad.exe  
> taskkill /f /pid 2152  

若有凝问或错误,请指出,我好及时改正,让我们一起进步!
email : vinson_bs@126.com
qq : 103 586 2795
敲门砖: 代码谱写人生