basarat
basarat

Reputation: 276313

How to open a `cmd` window from nodejs

Both of these start cmd in the background and I can't see the cmd window:

var cp = require('child_process');
cp.spawn('cmd');

and

var cp = require('child_process');
cp.exec('cmd');

I want to get into a state where I can see this window:

enter image description here

Upvotes: 1

Views: 1964

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1075587

You can use the one you're spawning to spawn another one that you can see, using the /c or /k option and start:

var cp = require('child_process');
cp.spawn('cmd', ['/C', 'start cmd.exe']);

Upvotes: 5

Related Questions