Windows: How to add batch-script action to Right Click menu

Actually, the current answer isn't out of date. I tried the exact same thing on Windows 10 and was able to add Run Batch script to the context menu of all folders in Windows.

This is the content of my batch script (won't work with UNC paths):

@ECHO OFF
ECHO %~n0 was called with the following arguments:
SET args=%*
IF NOT DEFINED args GOTO END
ECHO %*
:END
PAUSE

The registry changes I made can be replicated with this REG file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Run Batch script]
@="&Run Batch script"

[HKEY_CLASSES_ROOT\Directory\shell\Run Batch script\command]
@="\"H:\\BATCH_FILE_PATH\\context-batch.bat\" \"%1\""

This only adds a context menu item for all directories/folders in Windows. If you want it showing for each and every file instead, you can use this:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Run script]
@="Run &script"

[HKEY_CLASSES_ROOT\*\shell\Run script\command]
@="\"H:\\BATCH_FILE_PATH\\context-batch.bat\" \"%1\""

Alternatively, you can add your batch script to the Send To item list by creating a shortcut to your batch script and placing it under %APPDATA%\Microsoft\Windows\SendTo (or enter shell:sendto into the address bar)

If you want your script to show in the context menu that appears when you right click on the empty space within a directory (directory background?) you can use the following REG file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\Run Batch script]
@="&Run Batch script"
"Icon"="%SystemRoot%\\System32\\shell32.dll,71"

[HKEY_CLASSES_ROOT\Directory\Background\shell\Run Batch script\command]
@="H:\\BATCH_FILE_PATH\\context-batch.bat \"%V\""

You don't need the "Icon"="%SystemRoot%\\System32\\shell32.dll,71" line. It simply adds an icon to your context-menu that looks like this:

context menu icon windows


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

[HKEY_CLASSES_ROOT\Directory\shell\MyScript1]
@="Execute MyScript1"

[HKEY_CLASSES_ROOT\Directory\shell\MyScript1\command]
@="\"C:\\MyScriptsDirectory\\MyScript1Directory\\MyScript1.bat\" \"%1\""

I would recommend Default Programs Editor for this task. It is both more user friendly and arguably safer than editing the registry directly.

Choose Context Menu enter image description here

Select the extension you want to change. enter image description here

Choose Add... enter image description here

Give your command a Title, browse to the batch file and optionally pick an icon to represent your command. enter image description here

Save the context menu to the registry and you're good to go.