back2dos
back2dos

Reputation: 15623

Execute batch file in foreground

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?

Upvotes: 1

Views: 4957

Answers (1)

Avner Solomon
Avner Solomon

Reputation: 1506

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?

Upvotes: 1

Related Questions