Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a few programs that creates temp files or backup files or similar files that are not important. For example, GVim for Windows by default creates a backup file in filename.txt~.

I sometimes need to clean up a dir and remove all these files. I have made a simple .bat file for this. However, it is cumbersome to have to start up cmd, navigate to the folder, run the script. Especially since this is a script that I would like to run often on various folders. And I do not want to copy the script to multiple folders, as this would be a maintenance nightmare.

So, I was thinking, that the best solution would be to add a Right Click menu item that allows me to run the script. So that I can right click on a folder in Explorer and click Cleanup and then have my script run on this folder.

So my question is: How do I add a right click menu action that runs a custom batch script?

share|improve this question

1 Answer 1

up vote 9 down vote accepted

I have tried on Windows XP SP3 with this .reg key. Don't have Windows 7 at the moment to test it properly but it should be almost the same.

  1. Open notepad and paste the code from below.
  2. Edit as per your need.
  3. Save as MyScript1.reg
  4. Double click to import in registry.
  5. Test by Right click on any directory in Explorer
Windows Registry Editor Version 5.00

@="Execute MyScript1"

@="\"C:\\MyScriptsDirectory\\MyScript1Directory\\MyScript1.bat\" \"%1\""
share|improve this answer
I've edited your answer a bit. "Windows Registry Editor Version 5.00" is mandatory 'header' for .reg files. Otherwise Windows will refuse to inject the contents into registry. – extremko Jul 4 '12 at 10:48
+1 for pointing that one out. I totally forgot about that when c/p code. – Robert Schmidt Jul 4 '12 at 11:49
@Alex: Thanks for the edit, I appreciate it. – Robert Schmidt Jul 5 '12 at 11:05
I tried this. Now I can rightclick directyly on a folder, but it does not work if I rightclick inside a folder. Which is actually what I want. How to do that? – ervingsb Jul 9 '12 at 19:49
That's a different question than the "So that I can right click on a folder in Explorer and click Cleanup and then have my script run on this folder." – Robert Schmidt Jul 10 '12 at 9:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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