window批处理杀死指定端口进程,注意保存时使用ansi格式,运行输入端口即可 @echo off setlocal enabledelayedexpansion set /p port=请输入端口号: for /f "tokens=1-5" %%a in ('netstat -ano ^| find ":%port%"') do ( if "%%e%" == "" ( set pid=%%d ) else ( set pi
private void t_btn_kill_Click(object sender, EventArgs e) { int port; bool b = int.TryParse(t_txt_guardport.Text, out port); if (!b) { MessageBox.Show("请输入正确的监听端口"); return; } Process p = new Process(); p.StartInfo.FileName = "cmd.exe"
@echo off setlocal enabledelayedexpansion set /p port=请输入端口号: for /f "tokens=1-5" %%a in ('netstat -ano ^| find ":%port%"') do ( if "%%e%" == "" ( set pid=%%d ) else ( set pid=%%e ) echo !pid! taskkill /f /pid !pid!
#!/bin/sh #根据进程名杀死进程 ] then echo "缺少参数:procedure_name" exit fi PROCESS=`|grep -v grep|grep -v PPID|awk '{ print $2}'` for i in $PROCESS do echo "Kill the $1 process [ $i ]" $i done 引自:http://www.fengdingbo.com/shell-stop-procedure.html