Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute an exe(Inside Project structure) in Electron

While in developing mode, executing the exe is working well.

My code to launch the exe is

function LaunchExe() {
        var child = require('child_process').execFile;
        var executablePath = 'DemoExe/Sample.exe';
        var parameters = ['Hai', 'Test', 'Dat'];
        child(executablePath, parameters, function (err, data) {
            console.log(err)
            console.log(data.toString());
        });
}

But after packaging the Electron app, I can't launch the exe.

The command I use to build the exe is

electron-packager . --asar

Error code

 Error: spawn DemoExe/Sample.exe ENOENT
     at Process.ChildProcess._handle.onexit (internal/child_process.js:232)
     at onErrorNT (internal/child_process.js:407)
     at process._tickCallback (internal/process/next_tick.js:63)

Regards.

like image 590
Nandha Avatar asked Feb 25 '26 04:02

Nandha


1 Answers

Got to work with following steps,

1.package the Electron app using command

electron-packager .

2.Path to exe

path.join(__dirname, "DemoExe", "Sample.exe")

like image 101
Nandha Avatar answered Feb 27 '26 01:02

Nandha