比如: killtask.bat firefox杀掉所有firefox进程。
源代码如下:
点击(此处)折叠或打开
- @echo off
- rem Usage: killtask.bat process_name
- set process_name=%1
- setlocal EnableDelayedExpansion
- tasklist > c:\tasks.txt
-
for /F "tokens=1-6" %%i in ('findstr /I "%process_name%" c:\tasks.txt') do (
- set FIELD=%%j
- @echo TaskID: !
- if not "!FIELD!"=="" (
- rem kill the process
- @echo Start to kill the process !
- taskkill /F /PID !
- @echo process ! killed
- )
- )
《返璞归真--UNIX技术内幕》在全国各大书店及网城均有销售:
京东
亚马逊 China pub
上学吧 1号店