WebExtensions: Sending data to a Batch file?

186 views Asked by At

If a browser plugin is sending messages to a .bat file, what is the correct way to send that message? I have seen the following examples:

var sending = browser.runtime.sendNativeMessage("ping_pong", "ping");

And

var port = browser.runtime.connectNative("ping_pong");  
port.postMessage("ping");

In that example ping_pong is the name of the native application in the Windows registry.

Edit:

I am trying to use Native Messaging as described here:

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging

I have created a Firefox plugin which sends a string to a batch file using the code shown above. I have also created the registy entry and JSON file for the application as described in that link. The JSON file contains a link to the batch file so that the plugin knows what application to call.

The batch file can accept a parameter using %1. However the value of %1 is the name of the JSON file and not the message that was sent to it using JavaScript.

Edit 2:

It the example given in the link above it is a Python file that handles the standard input. Thus a batch file calls a Python file to handle the messaging. I used a Java file instead. This resolved the problem and it works without problems.

0

There are 0 answers