Run a non electron executable inside electron window

喜欢而已 提交于 2021-02-07 07:37:32

问题


I'm new to Electron and I'd like to run a non electron executable inside my main window. Is it possible to do that?

Here is my code:

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);
});

Thanks.


回答1:


I think you're on the right track except you need to do:

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

Instead of:

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

execFile docs here.



来源:https://stackoverflow.com/questions/45715989/run-a-non-electron-executable-inside-electron-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!