0

Google provides an example of calling native executables here. The actual "executable" is a .BAT file which calls python. I wanted to see if I could just run a .bat file with some typical OS or maybe even PowerShell commands. According to the help the executable needs to return UTF-8 JSON so I replaced the call to python with the following command:

TYPE %~dp0\SAMPLE.json

Where SAMPLE.json is a UTF-8 file with some JSON content.

Needless to say it does not work:

Error when communicating with the native messaging host.

According to the help it could be because of message size or text vs. binary output modes. I know of no way to get a batch file to "talk binary".

Is there any way to get Chrome to talk to text based CLI utilities like batch files, powershell...?

Marc
  • 13,011
  • 11
  • 78
  • 98
  • 2
    Relevant: [Q1](https://stackoverflow.com/questions/29587091/chrome-extension-message-passing-to-batch-file), [Q2](https://stackoverflow.com/questions/24764657/how-do-i-use-a-shell-script-as-chrome-native-messaging-host-application). In short: it's not a good idea to limit your tools - if you need to talk to an existing CLI utility, make a "proxy" native host using tools that are fit for the job. – Xan Nov 20 '16 at 13:10
  • Thanks. In my case I want to make a GUI for PowerShell so I want to talk as directly as possible to powershell.exe and can't much see the point of making a proxy if there's a direct way. – Marc Nov 20 '16 at 18:44
  • I'm curious if you ever figured something out, Marc. I think I agree with Xan's comment that PowerShell, etc may not be the best fit, but it certainly would be convenient for certain scenarios. – shaune Aug 11 '17 at 21:33
  • Nope, gave that one up as a bad job. – Marc Aug 15 '17 at 07:58
  • As did Google: https://blog.chromium.org/2016/08/from-chrome-apps-to-web.html – Marc Sep 14 '17 at 12:29

0 Answers0