我正在创建一个需要调用带有命令行参数的可执行文件的电子 GUI。
我已将可执行文件包含在public/libs/internalTool.exe
项目文件夹结构中。现在我想在应用程序中使用它(简化为仅相关部分):
import { remote } from 'electron';
const fs = remote.require('fs');
const path = remote.require('path');
const childProcess = remote.require('child_process');
export function processFile(inputFilePath: string, outputFilePath: string): void {
const internalToolPath = 'libs/internalTool.exe';
const inputDir = path.parse(inputFilePath).dir;
const outputDir = path.join(unencryptedDir, 'encrypted');
childProcess.execSync(`${internalToolPath} ${inputFilePath} ${outputFilePath}`);
}
但是,当我调用此函数时,它libs/internalTool.exe
说不存在并且它不运行命令。如何在我的代码中正确引用此 exe?