0

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.

I Newton
  • 33
  • 5
  • You have posted some random lines of javascript whilst making reference to a batch script/.bat file. Could you please at least explain how the two are interlinked because your question is unclear without clarification. – Compo Apr 13 '17 at 16:50
  • Thanks for editing your post, unfortunately it's still not clear to me what you are asking. Perhaps your manifest would help. – Compo Apr 13 '17 at 17:45
  • It's okay I solved it. I will but an edit again. – I Newton Apr 13 '17 at 18:58

0 Answers0