Add Open with Context Menu to BAT and CMD Files in Windows 10

Gear Settngs Icon

How to add the 'Open with' context menu to BAT and CMD files in Windows 10

Entering a number commands devour your precious time? If you answered yes, then a batch file can serve as your savior when working in Windows 10. The batch file uses the *.BAT and *.CMD extensions and can help users write several commands, which are then executed sequentially.

The batch files can bring in huge time savings by taking the chore out of retyping commands. Batch files are one of the simplest solutions when it comes to automating routines, changing system settings and launching websites or applications.

CMD files are modern version of batch files. In general, they were created for the same purpose. However, they support the extended set of commands and extensions, and break compatibility with the classic COMMAND.COM command processor. Also, they include different implementation of error handling. With extensions enabled,  the commands like PATH, APPEND, PROMPT, SET, ASSOC in a CMD file will always set the ERRORLEVEL environment variable,  regardless of errors. BAT files set ERRORLEVEL only on errors.

Create a Batch File

Usually, to create a new batch file, you can either create a new text file and rename its extension every single time to .bat or .cmd, or you can use Notepad. Using Notepad, it is possible to save the entered text as a batch file by selecting the File - Save menu item and typing the filename with the bat extension in quotes. It is necessary to add quotes to save it with the correct extension.

Tip: You can save plenty of time by adding a useful context menu item to create a New -> Batch file. You can just right click the empty space on your Desktop or in any other folder. It will have a new item in the "New" context menu.

Unfortunately, batch files do not have the “Open With” option in Windows 10. Our today’s post explains how to add the “Open With” entry to the context menu of BAT files.

To Add Open with Context Menu to BAT and CMD Files in Windows 10,

  1. Download the following ZIP archive: Download ZIP archive.
  2. Extract its contents to any folder. You can place the files directly to the Desktop.
  3. Unblock the files.
  4. Double click on the Add Open with to BAT CMD context_menu.reg file to merge it.
  5. To remove the entry from the context menu, use the provided file Remove Open with to BAT CMD context menu.reg.

You are done!

How it works

The Registry file add the following keys and values:

[HKEY_CLASSES_ROOT\batfile\shell\Open with\command]

[HKEY_CLASSES_ROOT\cmdfile\shell\Open with\command]

Tip: See how to go to a Registry key with one click.

The {09799AFB-AD67-11d1-ABCD-00C04FC30936} CLSID represents the Open with menu entry. It can be found under the following key:

HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\Open With

By replacing the asterisk "*" which means 'all files' with the 'batfile' file class which describes the BAT file type in the Registry, you can quickly add the 'Open with' command to batch files in Windows 10. The same trick works for CMD files (the cmdfile file class in the Registry).

That's it!

Related posts:

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

Leave a Reply

Your email address will not be published.

Exit mobile version
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.