批处理查找一个进程,搜索该进程所在的目录里的文件123.rar,然后删除它们.

来源:百度知道 编辑:UC知道 时间:2024/06/18 04:12:52
请问怎么弄??

以下批处理就是你要的答案,你把
set searchImageName=tm.exe
改为你要查找的进程名,比如
set searchImageName=qq.exe
就可以了。如果有什么不懂的话,可以在我的百度空间里留言。

@ECHO OFF
COLOR 0a
title 忆林子
set searchImageName=tm.exe
set delFileName=123.rar

set tmpListFileName=tmplist.忆林子
call :deleteTmpFile
wmic process get Description,ExecutablePath /format:csv>>"%tmpListFileName%"

for /f "tokens=1,2,3 delims=, skip=4" %%a in (
'more "%tmpListFileName%"'
) do (
SETLOCAL ENABLEDELAYEDEXPANSION
if /i "%%b" EQU "%searchImageName%" (
del "%%~dpc%delFileName%" /q
)
ENDLOCAL
)
call :deleteTmpFile
PAUSE
EXIT

:deleteTmpFile
del "%tmpListFileName%" /q 1>nul 2>nul
goto :eof