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

在GitHub Actions中用cmd后台运行CoreServer.exe遇路径错误求助

解决GitHub Actions中cmd环境后台运行CoreServer.exe的问题

问题分析

出现'.' is not recognized as an internal or external command错误的核心原因:

  • Windows cmd不支持类Unix的./相对路径写法,需改用Windows原生的.\格式
  • cmd中&是命令分隔符,并非后台运行语法,要实现后台启动程序必须使用start /b命令

修正方案

1. 修正后台启动命令

将Workflow中启动CoreServer的步骤替换为:

- name: Start CoreServer.exe in the background
  shell: cmd
  run: start /b .\Debug\CoreServer.exe -c -s

参数说明:

  • start /b:cmd环境下后台运行程序的标准命令,/b表示不新开控制台窗口,在当前会话后台执行
  • .\Debug\CoreServer.exe:cmd中合规的相对路径写法,.\代表当前工作目录,\是Windows系统的路径分隔符

2. 统一cmd环境的等待命令(可选)

原sleep 7是PowerShell专属命令,若要全程使用cmd环境,需替换为cmd支持的timeout命令:

- name: Wait 7 seconds
  shell: cmd
  run: timeout /t 7 /nobreak

/nobreak参数用于避免意外中断等待(GitHub Actions无交互场景下可省略,但保留更严谨)

3. 验证工作目录(可选)

若不确定Debug目录是否在当前工作路径下,可添加目录检查步骤确认:

- name: Check current directory contents
  shell: cmd
  run: dir

修正后的Workflow关键片段

- name: Start CoreServer.exe in the background
  shell: cmd
  run: start /b .\Debug\CoreServer.exe -c -s

- name: Wait 7 seconds
  shell: cmd
  run: timeout /t 7 /nobreak

- name: See status
  shell: cmd
  run: netstat -ano | findstr "3334 3333"

注:cmd中netstat无-ntp参数,改用-ano配合findstr筛选目标端口

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 14:10:21