在电子窗口中运行非电子可执行文件



我是Electron的新手,我想在我的主窗口中运行一个非电子可执行文件。有可能做到吗?

这是我的代码:

mainWindow = new BrowserWindow({width: 860, height: 645})
mainWindow.loadURL('https://url.com/')
const { execFile } = require('child_process');
const child = execFile('C:\test\content.exe', {cwd: 'C:\test\'}, (error, stdout, stderr) => {
if (error) {
throw error;
}
console.log(stdout);
});

谢谢。

我认为你走在正确的轨道上,除了你需要做:

const { execFile } = require('child_process').execFile;

而不是:

const { execFile } = require('child_process');

execFile文档在这里。

最新更新