如何永久从Node.js执行Windows批处理文件?

我正在运行Windows 10,我想从forever(v3.0.0)执行Windows .bat脚本

forever已在全球范围内安装且运行良好,并且我已成功用于启动其他应用程序。

在这种情况下,我使用的forever JSON配置文件如下:

{
  "uid": "MyApp","command": "cmd.exe","script": ["/c",".\\scripts\\init-myApp.bat"],"sourceDir": "C:\\myApp","logFile": "C:\\myApp\\forever.log","outFile": "C:\\myApp\\out.log","errFile": "C:\\myApp\\error.log","append": true
}

基于以下事实,这似乎是正确的:

但是当我尝试运行此代码时,我收到验证器错误:

internal/validators.js:120
    throw new ERR_INVALID_ARG_TYPE(name,'string',value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
    at validateString (internal/validators.js:120:11)
    at Object.join (path.js:375:7)

因为forever/cli.js calls path.join on the script option before passing it along to forever-monitor

我也尝试过以下组合:

{
  "uid": "MyApp","script": ".\\scripts\\init-myApp.bat",...
}

仅启动cmd而不执行批处理文件,并且

{
  "uid": "MyApp","command": ["cmd.exe","/c"],...
}

forever-monitor中引发错误,因为它假定command是字符串,而不是数组。

有什么方法可以传递必要的/c参数,还是可以使用forever执行批处理脚本?

iCMS 回答:如何永久从Node.js执行Windows批处理文件?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/1994961.html

大家都在问