-1

Hello guys im trying to make an extension that open any exe on user computer by simply textbox.user will write the path of exe he wants to open and i need to take that path to batch file and run it is that possible if that so how? my current batch file only open one path but i want it to take paths from user and open that exe on path location

Esclade
  • 13
  • 5

1 Answers1

1

Well, Native Messaging does not allow you to pass command line parameters. It will only allow communication using the Native Messaging protocol (length + JSON-enconded message).

So you need to make a single native host that is able to read an incoming message, decode it and execute the command you want, i.e.:

// Extension side
chrome.runtime.sendNativeMessage('native.app.id.here', { command: "calc.exe" });

and then the app will receive, through STDIN, the length of the message + {"command":"calc.exe"}

Actually writing code that will decode that message using batch scripting is a terrible idea, but doable in principe. You should probably write an actual program in a language with support for JSON manipulation to handle this. See also this question.

Community
  • 1
  • 1
Xan
  • 74,770
  • 16
  • 179
  • 206
  • thank you so i should not use batch file to open local exe – Esclade Aug 04 '15 at 10:59
  • You can, but if you want to pass data (like which file to launch), batch is a poor choice. – Xan Aug 04 '15 at 11:00
  • is it possible with c++? – Esclade Aug 04 '15 at 11:01
  • Certainly. It's just reading from `cin` _according to the protocol_, then you'll need to parse the string somehow - shouldn't be difficult if you follow a fixed format, and then `fork`/`exec` to spawn a new process and execute it. Sorry, but actual implementation is beyond the scope of my answer. If you have more concrete questions about it, make a new question. Actually, if someone makes such a generic "launcher" native host and leaves it open-source it will be very useful. – Xan Aug 04 '15 at 11:05
  • yeah its hard to imagine im just intern and they gave me this project and i have no idea – Esclade Aug 05 '15 at 08:33