Search code examples
electronelectron-builder

Passing command line arguments to electron executable (after installing an already packaged app)


I'm trying to pass command line arguments to my already packaged app on execution. (Already packaged with electron-builder and installed the .dmg on my mac)

I navigated into the /Applications/myApp.app/Contents/MacOS folder where the application executable is located. Then i run. exec myApp --myNewArgument theFancyValue For some reason "myNewArgument" does not appear in my process.argv array.

Am i missing anything? I thought the arguements will automaticly be passed to my electron main process.

I am thankfull for any help.


Solution

  • Yes, the passed command line arguments appear in the process.argv array, but only from the main process.

    From a renderer process, you'll need to access the main process arguments using remote.process:

    require('electron').remote.process.argv