簡體   English   中英

'。 未被識別為內部或外部命令、可運行程序或批處理文件

[英]'.' is not recognized as an internal or external command, operable program or batch file

嘗試通過shell運行cpp程序,在nodejs中使用exec命令,我在node.js中寫了下面的exec命令。 (順便說一句,我正在嘗試在 Windows 中)

exec(`g++ ${fileData.filepath} -o ${outPath} && cd ${outputPath} && ./${jobId}.exe,
   (error,stdout,stderr)=>{
                if(error){
                    reject({error,stderr})
                }
                if(stderr){
                    reject(stderr)
                }
                resolve(stdout)
            })

該程序正在存儲在預期以 .exe 格式存儲的位置。 我得到一個錯誤是“。” 不被識別為內部或外部命令、可運行程序或批處理文件。 幫我解決這個問題。

只需從執行exe文件的 exec 命令中刪除./ ,因為./用於 linux,而不是 Windows (當您已經在包含可執行文件的目錄中時)。

exec(`g++ ${fileData.filepath} -o ${outPath} && cd ${outputPath} && ${jobId}.exe`,
   (error,stdout,stderr) => {...})

對於可執行文件,您不需要執行./ 只是 filename.exe 應該可以工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM