1.用记事建一新文档
2.拷贝以下内容到文档:
::=================================================
@echo off & setlocal enabledelayedexpansion
set ver=1.45
::版本
set M=1
::模式
set muller=1
set num=5
::覆盖模式
::次数
title 文件删除工具 V!ver!
mode con: cols=80 lines=25
color 2a
:begin
set File=0
set Filedel=0
set Fail=0
set cacls=0
echo.
echo ╭————————————┤ 文 件 删 除 工 具 ├————————————╮
echo │ │
echo │ 说明: │
echo │ │
if /i not !M!==1 echo │ 请将要删除的文件拉到该程序图标上即可删除。
│
if /i !M!==1 echo │ 请将要删除的文件拉到该程序图标上或窗口中即可删除。(最好是拖到该
│
if /i !M!==1 echo │程序图标上)
│
if /i !M!==1 echo │
│
echo │ │
echo ╰———————————————————————————————————-╯
echo.
if not *%2*==** set File=1
if not *%1*==** goto start
if /i not !M!==1 pause && goto begin
set /p str=请把文件拉到本窗口后回车:
if not exist !str! echo. && echo 请确认路径合法! && pause >nul && cls && goto begin
call "%~0" !str! && exit
:start
pause
cls
:manyFile
if *%1*==** (
set File=0
if !Filedel!==1 del info.txt;taskpid.txt
if !fail!==1 goto err
goto success
)
if "%~x1"==".exe" (
set Filedel=1
goto taskkill
)
:go
if !file!==2 goto mangFile_2
echo.
echo /// ///
echo // - - //
echo ( o o )
echo +-------oOOo-----(_)-----oOOo---------+
echo ^| ^|
echo ^| 正在删除中, 请稍侯...... ^|
echo ^| ^|
echo +----------oooO-------Oooo------------+
echo.
echo.
:mangFile_2
del /f /a /q //?/%1 >nul 2>nul
rd /s /q //?/%1 >nul 2>nul
if exist %1 (
if !cacls!==1 goto err
echo Y|cacls %1 /t /c /g !username!:f >nul 2>nul
set cacls=1
goto mangFile_2
)
if !muller!==1 (
for /l %%i in (1,1,!num!) do (
copy>nul /y nul %1
del %1
)
)
if !file! geq 1 (
shift
set file=2
goto manyFile
)
:success
del info.txt;taskpid.txt
cls
echo ============
echo 删除成功!
echo ============
echo.
echo.
echo 按任意键退出. . . & pause >nul
goto :eof
:err
if !file! geq 1 (
set Fail=1
if !file!==1 set file=2
shift
goto manyFile
)
del info.txt;taskpid.txt
cls
echo ============
echo 删除失败!
echo ============
echo.
echo.
echo 可能有以下原因:
echo.
echo.
echo 1.文件正在被使用
echo.
echo 2.磁盘写了保护
echo.
echo.
echo 按任意键退出. . . & pause >nul
exit
:taskkill
if !file!==2 goto taskkill_then
cd /d !temp!
@echo for each task in getobject _ >task.vbs
@echo ("winmgmts://./root/cimv2:win32_process").instances_ >>task.vbs
@echo wscript.echo task.handle^&">>>"^&task.executablepath:next >>task.vbs
cscript //nologo task.vbs > info.txt && del task.vbs
:taskkill_then
set process=%1
set process="!process:"=!"
find >taskpid.txt 2>nul /i !process! info.txt || goto Del_Temp_File
for /f "usebackq skip=2 tokens=1 delims=>>> " %%i in (taskpid.txt) do taskkill.exe >nul
2>nul /f /pid %%i
:Del_Temp_File
goto go
3.保存文档为del.bat,生成批处理文件
4.拖无法删除的文件到该批文件.