OK, the problem is with the quotes. Since %3 may contain spaces, you should use "%3" in the command line. However inside the BAT file %1 must have no quotes. Here's an improved version of the BAT file: set list=%1 set list=%list:"=% for /F "delims=" %%i in (%list%) do del "%%i" del %1
The first line will assign the filename to list
, the second line will remove the quotes from list
, and then it can be used in the for
Assuming your DeleteOK.vbs
is more powerful than the del
DOS command (maybe it takes care of read-only files, or UAC protection), you may use this line: for /F "delims=" %%i in (%list%) do G:\...\DeleteOK.vbs "%%i"