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
Asked
Active
Viewed 231 times
-1
-
Batch can't interact with GUIs. – SomethingDark Aug 04 '15 at 07:46
-
1It _is_ possible with a Native Host module, but the question is horribly broad with no effort demonstrated. – Xan Aug 04 '15 at 07:56
-
yes im using native messaging host how is it possible? – Esclade Aug 04 '15 at 08:21
-
Demonstrate what you've done already (or what you can do without help), and what specifically is the problem. – Xan Aug 04 '15 at 08:57
-
Why not output the path to a text file? You can use batch to get the path in there. – Happy Face Aug 04 '15 at 08:59
-
http://stackoverflow.com/questions/31745405/native-messaging-extension-connectnative-not-working-on-localhost i have this it calls batch file with messaging and my batch file only open one exe but i want it to open any exe depends on the input – Esclade Aug 04 '15 at 10:30
-
@Xan you mean i get the input from textbox written to texfile and batch read textfile? – Esclade Aug 04 '15 at 10:31
-
@darkfang Probably because there is no write access to the fs. – Xan Aug 04 '15 at 10:48
-
@darkfang how can i do that? – Esclade Aug 12 '15 at 10:57
1 Answers
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.
-
-
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
-
-
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