Skip to content
This repository has been archived by the owner on Oct 2, 2020. It is now read-only.

Question : How to pass custom command line arguments ? #45

Closed
s-a opened this issue Jul 17, 2015 · 5 comments
Closed

Question : How to pass custom command line arguments ? #45

s-a opened this issue Jul 17, 2015 · 5 comments

Comments

@s-a
Copy link

s-a commented Jul 17, 2015

Hi! I d like to pass custom command line arguments to have them available at process.argv. Is there a way to submit values?

@mafintosh
Copy link
Collaborator

You just pass then after your script file

// save as test.js
console.log(process.argv)

and then

npm install -g electron-prebuilt
electron test.js hello world

@s-a
Copy link
Author

s-a commented Jul 17, 2015

Thanks for the quick response.
I have tried this but getting always this result

["C:\Users\Stephan\AppData\Roaming\npm\node_modules\electron-prebuilt\dist\electron.exe", "--type=renderer", "--no-sandbox", "--enable-deferred-image-decoding", "--lang=de", "--node-integration=true", "--device-scale-factor=1", "--font-cache-shared-mem-suffix=2764", "--enable-pinch-virtual-viewport", "--enable-delegated-renderer", "--num-raster-threads=1", "--channel=2764.8.56440853\521306387", "/prefetch:673131151"]

Here is my code

var electron = require('electron-prebuilt')
var proc = require('child_process')

// will something similar to print /Users/maf/.../Electron
console.log(electron)

// spawn electron
var child = proc.spawn(electron, ["./app", "foo=bar"]);

@s-a
Copy link
Author

s-a commented Jul 17, 2015

I just figured out that it works for me if I hold a copy of process.argv in process.env

process.env.XXXargv = JSON.stringify(process.argv)  ;

@watsoncj
Copy link

watsoncj commented Sep 1, 2017

The renderer process can access the main process argv like so:

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

@jasondavis
Copy link

jasondavis commented Jan 5, 2018

can these command line args be passes to an electron apps .exe windows version of the app

like:

my-electronjs-app.exe -args

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants