Depending on what you are trying to delete you can use the following command:
del /f /q /s "FILENAME.EXT"
You'll need th quotes if the file name contains spaces & possibly if there are special characters involved. (use the
^ to 'escape' the special character) Be very careful with the
/q switch as it will not prompt you to delete. It will just delete.
/f will delete any files that are read only.
/s will delete files from all subdirectories.
Make sure you start from the topmost level where you think the file is located at. If you have one partition you may want to use the
%HOMEDRIVE% or
%SystemDrive% Environment Variable to start at the root of the drive if you don't know where where exactly to delete the files from.
Ex:
@echo off
del /f /q /s "%SystemDrive%\virus.exe" || echo virus.exe not found.
del /f /q /s "%SystemDrive%\trojan.dll" || echo troja.dll not found.
Or you could go farther and do this:
@echo off
del /f /q /s "%SystemDrive%\%1" || echo %1 not found.
And then at the command line you could type:
BatchFileName name being, of course, the name that you saved the batch file to. This way you can delete whatever file you would like without having to modify the batch file everytime. And you can add
>nul 2>&1 to get rid of any pesky XP Command Prompt built-in errors like so:
del /f /q /s "%SystemDrive%\%1" >nul 2>&1 || echo %1 not found.
I'm not 100% sure that the
>nul 2>&1 is in the right place. It may need to be at the end of the line. Try it and see.