Man*_*ira 6 executable electron
我是 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);
});
Run Code Online (Sandbox Code Playgroud)
谢谢。
我认为你走在正确的轨道上,除了你需要做的:
const { execFile } = require('child_process').execFile;
Run Code Online (Sandbox Code Playgroud)
代替:
const { execFile } = require('child_process');
Run Code Online (Sandbox Code Playgroud)