You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用PM2为.exe程序传递执行参数?

解决PM2启动.exe程序传递参数无效的问题

方法1:调整命令格式

在Windows环境下,直接使用原命令可能因路径解析问题导致参数无法传递,尝试将可执行文件路径用双引号包裹:

pm2 start "go-cqhttp_windows_amd64.exe" -- -faststart

如果exe文件不在当前工作目录,需填写完整绝对路径,示例:

pm2 start "D:\your-path\go-cqhttp_windows_amd64.exe" -- -faststart

方法2:使用PM2配置文件(更可靠)

创建ecosystem.config.js配置文件,内容如下:

module.exports = {
  apps: [
    {
      name: "go-cqhttp",
      script: "./go-cqhttp_windows_amd64.exe",
      args: "-faststart"
    }
  ]
}

执行启动命令:

pm2 start ecosystem.config.js

这种方式能确保参数被正确传递,也便于后续进程管理。

验证参数是否生效

通过以下命令查看进程启动参数,确认-faststart是否被正确传递:

pm2 show go-cqhttp

在输出的args字段中可查看对应参数。

内容的提问来源于stack exchange,提问作者AwCat

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 07:20:36