I want to delete files from a list stored in a text file from a context menu in windows 7. I worked out the command, and it works fine if I run the script in command prompt in the directory I want to clean. 

I want to make the script accessible via context menu so when I right click on the folder and click on the shortcut command, it will delete the files in that folder listed in a separate text file. This is what I've tried:

I put my command in registry. It showed up, but does not run as I expected. This is my command:

```
for /f %i in (D:\Desktop\Documents\deletelist.txt) do del %i

```

This is the registry command:

```
C:\Windows\system32\cmd.exe for /f %i in (D:\Desktop\Documents\deletelist.txt) do del %i

```

After I clicked this on the context menu, the command prompt window switches the current directory to C:\Windows\system32\ and doesn't run anything. Can anyone tell me what's wrong with this?

Edit:

Sorry if I didn't make myself clear here. The command will run in C:\Windows\system32\ because no current directory was passed as parameter. It runs fine if I go to the path I want and run it. Not ok if the directory is dynamic.

I gave up on that approach. Back to batch, I guess. My registry entry:

```
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Delete files\command]
@="\"D:\\Desktop\\Documents\\delfil.bat\" %1"

```

And my bat file:

```
start /D %1 /B for /f "usebackq tokens=*" %%i in (D:\Desktop\Documents\deletelist.txt) do del /q "%%i"
exit

```

It works but using start leaves the command window stay up and not auto closed. Also, I can't delete folders and files indiscriminally. For example, I have a deletelist.txt look like this:

```
Pale Moon temp
Temp
007_copy.jpg
008_copy.jpg
009_copy.jpg
010_copy.jpg
011_copy.jpg
012_copy.jpg
013_copy.jpg
014_copy.jpg
015_copy.jpg
016_copy.jpg
017_copy.jpg
018_copy.jpg
019_copy.jpg
020_copy.jpg
021_copy.jpg
022_copy.jpg
credits.jpg
lol.reg

```

There are 2 folders and the other are files. If I run (del /q "%%i"), the files in current folder and subfolders are deleted but the subfolders are remained. I have to run a separate batch with (rd /s /q "%%i") to get rid of the folders. Any clean way to just run a command to scan the list, grab the line, and delete the item regardless if it is folder or file.

Thank you.