0

I want to delete a large number of files from a USB hard drive, I found that a faster way to delete is to use the cmd console delete function. I would like to add the option to do this into the context menus for files and for folders.

I found this tutorial that shows to create a .bat file and add it to the registry, however when I try to use it nothing happens, I did manage to get the option to appear in the context menu by adding the key to Computer\HKEY_CLASSES_ROOT*\shell\Fast Delete\command instead of the Computer\HKEY_CLASSES_ROOT\Directory\shell\Fast Delete\command like it says in the tutorial, although when I try to use it from the right click nothing happens.

The .bat file is as follows:

@ECHO OFF
ECHO Delete Folder: %CD%?
PAUSE
SET FOLDER=%CD%
CD /
DEL /F/Q/S "%FOLDER%" > NUL
RMDIR /Q/S "%FOLDER%"
EXIT

and the location of the .bat file is "C:\Extra Windows Tools\delete.bat" i did add **"C:\Extra Windows Tools** to the system path variable.

I have tried using cmd /c "cd %1 && delete.bat" like the tutorial says and nothing happens I have also tried "C:\Extra Windows Tools\delete.bat" %1, that I found on another website.

Any help that you can give will be greatly appreciated

*Edit 1 The problem is partly to do with permissions and partly because it doesnt seem to work when i right click on folders only on files. with the permissions problems i go through these steps which allows me to delete files using the normal delete option but not with the batch script.

*Edit 2 - I have sorted the permissions, the problem is because the script doesnt seem to work on folders

*Edit 3 - I have fixed the problem, i added the key with the suggestion below to Computer\HKEY_CLASSES_ROOT\Directory\shell\Fast Delete and it now works on folders. Thank you for all your suggestions

  • What debugging / troubleshooting have you done? Have you tried temporarily renaming the script, and then clicking on the menu entry — to see whether it gives you an error message? Have you tried writing to a log file from the batch file? Do you expect a CMD window to pop up when you do this? (Have you seen anything that would suggest that this will happen?) If not, what do you expect to happen when you pause? – Scott Mar 2 '18 at 18:56
  • To be completely honest this is the first time i have tried anything like this i will try your suggestions, – Liam Mar 2 '18 at 19:02
  • I changed the command key to the location of the .bat file again and tried it out on a random file in a folder on my c drive and it worked a menu popped up asked for any key then deleted it, however when i tried to use this on my USB hard drive (taken from a previous laptop) the console flashes up then dissapears, what should i do? – Liam Mar 2 '18 at 19:04
  • Edit your question and include all information about what you have tried and what happened. – Scott Mar 2 '18 at 19:17
  • You will need to restart Explorer for the system environment variable to be read. If you reboot, make sure you use Restart, not Shut down, as with default settings this hibernates, which doesn't restart anything. – AFH Mar 2 '18 at 19:19
0

Replace "%1" with "%V" in the registry key for right click menus. This will pass the object that was clicked on.

0

The problem is partly to do with permissions and partly because it doesnt seem to work when i right click on folders only on files. with the permissions problems i go through these steps which allows me to delete files using the normal delete option but not with the batch script.

I have fixed the problem, i added the key with the suggestion below to Computer\HKEY_CLASSES_ROOT\Directory\shell\Fast Delete and it now works on folders.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.