Question

Having a nodejs app (node-webkit in fact), how can I launch a batch file in foreground in whatever folder it is in?

So far I have succeeded in running the batch file with the following:

require('child_process').spawn(pathToBat, [], dirOfBat)

However this is run in the background.
Edit for clarifaction: in foreground means, that a separate window is opened to display all output generated by the batch file.

I've tried all sorts of variations with child_process.exec and with passing the batch file to both start and cmd but I can't seem to make it work. Any hints?

Was it helpful?

Solution

From my knowledge you can't. But you can pipe the steams child.stdout and child.stdin to process.stdout and process.stdin

Edit

After the explanations from your comment I think you're looking for exec or execFile.

var exec = require('child_process').exec;
exec('explorer'); exec('notepad'); exec('start cmd');

Something like this?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top