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

VSCode终端无法运行编译生成的.exe程序问题求助

VSCode终端无法运行编译生成的.exe程序问题求助

刚接触C语言编译、时隔多年重新用VSCode的话,遇到这种问题确实容易懵,我来帮你梳理下原因和解决办法:

问题回顾

你编译出了program.exe文件,在Windows CMD当前目录下直接输入program.exe能正常运行,但在VSCode终端里执行同样的命令却报错:

program.exe : The term 'program.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:1 char:1

  • program.exe
  • CategoryInfo : ObjectNotFound: (program.exe:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException

常见解决办法

  • 用相对路径执行程序:VSCode默认终端是PowerShell,它和CMD的路径规则不一样——在PowerShell里运行当前目录下的可执行文件,必须加上相对路径前缀.\\,也就是输入 .\program.exe 就能正常启动程序了。
  • 确认终端当前目录是否正确:有时候VSCode的终端可能没自动切换到你的.exe所在文件夹,你可以先输入 pwd(PowerShell命令)或者 cd(CMD命令)查看当前路径,确认和.exe的存放目录一致;如果不一致,用 cd 你的exe文件夹路径 切换后再尝试运行。
  • 切换VSCode终端类型为CMD:如果你更习惯CMD的操作逻辑,可以把VSCode默认终端换成CMD:点击终端面板右上角的下拉箭头,选择「选择默认配置文件」,选中「Command Prompt」,之后新开的终端就会用CMD模式,直接输入program.exe就能运行了。

备注:内容来源于stack exchange,提问作者N1teShad0w

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.21 11:14:34