如果 detached=true,则 NodeJS 生成不起作用

时间:2021-03-01 18:01:56

标签: node.js

我需要在 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"',这将使命令失败。

感谢任何帮助。

0 个答案:

没有答案