Execute Batch file using NativeMessagingHosts

Hi there, I’m trying to create a private addon for Firefox ESR and add a context menu and launch either a batch file or an executable application when selecting text.

I’ve added the relevant registry keys to, they point to the manifest.json


I’m not certain if I’ve picked the right location for the registry entries. The code is incomplete and I’m hoping to learn if I’ve picked the right location for the registry keys and how to launch an app or batch file via the javascript file.


      id: "launchBatch",
      title: "Launch Batch File",
      contexts: ["all"]

browser.contextMenus.onClicked.addListener((info, tab) => {
  if (info.menuItemId === "launchBatch") {
  //browser.runtime.sendNativeMessage does not seem to work and just returns errors

My attempts to run any batch files or executable have failed. I’m not sure what format the manifest.json file should be in either since i periodically see warnings in Firefox when installing the addon. I’m using windows 10.

Here is the error I get in the debugger when I right click on the context menu leading me to believe I have not added the registry key in the correct place. The predicament is extra confusing since I have remnants of old Firefox versions in my registry.

Error communicating with native application: Error: No such native application launchBatch

My registry

  1. What are the values of the registry keys?
  2. Native Messaging Manifest
    a) Where did you put the NMM?
    b) What text does the NMM contain?
    Especially the “name” field:
    “On Windows, it must match the name of the registry key you create, that contains the location of the native messaging manifest.”

Have you installed the Native Messaging Example Extension?
It’s a good learning experience, and:
To assist in troubleshooting on Windows, there is a script called check_config_win.py . Running this from the command line should give you an idea of any problems.

1 Like