When the file, directory or file is opened some programs, then later you want to delete a file or directory, and can not be deleted, with this script you can easily remove.
-
Download Handle.zip file https://docs.microsoft.com/zh-cn/sysinternals/downloads/handle
extract to any place -
bat batch
OFF @echo
REM handle executable file
the SET "handle = C: \ the Users \ TOO \ Desktop \ the Handle \ Handle.exe"
REM files to be deleted
SET "appfile = C: \ Users \ too \ Desktop \ test"FOR /F "tokens=3" %%a IN ('%handle% -nobanner %appfile% ^| FINDSTR /V explorer.exe') DO (
@echo %%a
@taskkill /F /PID %%a
)
NOTE: After the lifting of possession can easily delete the file.