How do you package an external exe file in your app


#1

Hello I am trying to call a .exe file in my code and am wondering how I can include the exe file to be included into my installer. Along with includding it I am also wondering how I should find the directory. Currently I am just calling it statically by hard coding in the location of the .exe file but that obviuolsy wont work.
Tried storing the location like such
var exePath = 'file://' + __dirname + '/run.exe';
but the npm start and the installer create a bin folder which is remade every run. Any help would be appreciated.


#2

Hi !

const app = require('electron').app; 
/* or require('electron').remote.app if you are in the main process */

console.log(app.getAppPath());

should be what you’re looking for.


#3

For anyone that is looking to do this the problem was that I was not adding my exe file while building my application. You need to edit your build.js file to look like this to include exes.

var paths = {
    jsCodeToTranspile: [
        'app/**/*.js',
        '!app/main.js',
        '!app/spec.js',
        '!app/node_modules/**',
        '!app/lib/**'
    ],
    copyFromAppDir: [
        './main.js',
        './spec.js',
        './node_modules/**',
        './lib/**',
        './**/*.exe' <- This adds your exe file so you can call it 
    ],
}