I'm working with nodejs and the child process module to execute mands on my platform. To do that, I use the spawn function.
Here's my code:
var spawn_execution = executor.spawn(mand, args);
spawn_execution.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
spawn_execution.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
Nothing fancy. So I tried a couple of mands that worked like
executor.spawn('C:/path/to/ffmpeg.exe', [...]);
But when I try to use a native windows mand, it does not work. For instance, I tried:
executor.spawn('del', ['C:\\my\\file\\to\\delete']);
When executing this, I've got a ENOENT error which means that the file is not found. So I did another thing:
executor.spawn('C:/my/script-delete.exe', ['C:\\my\\file\\to\\delete']);
This script-delete.exe just contains:
del %1
So why does the spawn function need to have a script file? Why does it not work with native windows mand? Do you know a way to make it work with a native mand?
Thank you!
I'm working with nodejs and the child process module to execute mands on my platform. To do that, I use the spawn function.
Here's my code:
var spawn_execution = executor.spawn(mand, args);
spawn_execution.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
spawn_execution.stderr.on('data', function (data) {
console.log('stderr: ' + data);
});
Nothing fancy. So I tried a couple of mands that worked like
executor.spawn('C:/path/to/ffmpeg.exe', [...]);
But when I try to use a native windows mand, it does not work. For instance, I tried:
executor.spawn('del', ['C:\\my\\file\\to\\delete']);
When executing this, I've got a ENOENT error which means that the file is not found. So I did another thing:
executor.spawn('C:/my/script-delete.exe', ['C:\\my\\file\\to\\delete']);
This script-delete.exe just contains:
del %1
So why does the spawn function need to have a script file? Why does it not work with native windows mand? Do you know a way to make it work with a native mand?
Thank you!
Share Improve this question asked Oct 10, 2013 at 8:33 user734613user7346131 Answer
Reset to default 9It doesn't work as the internal mands can't be found from executor.spawn
only cmd.exe
knows them.
So it works from a batch file or when you use something like
executor.spawn('cmd.exe', ['/C', 'del', 'C:\\my\\file\\to\\delete']);