Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

child_process.spawn for windows? #4240

Closed
kataik opened this issue Nov 5, 2012 · 1 comment
Closed

child_process.spawn for windows? #4240

kataik opened this issue Nov 5, 2012 · 1 comment

Comments

@kataik
Copy link

kataik commented Nov 5, 2012

Hi all,
If I try to execute the following using node v0.8.12:

(require('child_process').spawn('dir', [], { stdio: 'inherit' })).on('exit', function(code) { console.log(code) })

on windows 7, I get
CreateProcessW: The system cannot find the file specified.
127

Because I need to pipe the output of the child process into a stream run-time, using exec is not an option. Will spawn ever be able to used in windows?

Best,
Kornel

@piscisaureus
Copy link

This will never work, because "dir" is not an executable, it's a command built into the shell. (Press Windows+R and try to run "dir" there, you'll get the same result.)

Instead, try this:

require('child_process').spawn('cmd', ['/c', 'dir'])

Oh, and please use the mailing list for these questions next time. This is not a support forum.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants