Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a non electron executable inside electron window

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.

like image 355
Manuel Franqueira Avatar asked Aug 16 '17 14:08

Manuel Franqueira


1 Answers

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.

like image 170
Joshua Avatar answered Oct 18 '22 21:10

Joshua