我需要在 NodeJS 中生成一个新的分离进程。
此处显示的代码不起作用:
const CHILD_PROCESS = require('child_process');
var cmd = 'dir > d:\dir.txt'
var params = cmd.split(' ')
CHILD_PROCESS.spawn('cmd', params, {
detached: true,
stdio: 'ignore'
})
此外,如果 cmd = 'dir | find "bytes" > d:\bytes.txt'
则 spawn()
将在 "bytes"
中转换 '"bytes"'
,这将使命令失败。
感谢任何帮助。