Read Windows command line option in Electron renderer process

吃可爱长大的小学妹 提交于 2019-12-05 19:53:56

All your arguments are inside the process.argv array. So if you are trying to access the arguments from the main process you can just use the following:

//the command you called is always argv[0]
process.argv[0] == "C:\Program Files\MyApp.exe"

//every other argument, separated by spaces, is in the array in order
process.argv[1] == "-debug"

If you are trying to access them from a renderer process however, you need to use electron remote.

const remote = require('electron').remote

//the command you called is always argv[0]
remote.process.argv[0] == "C:\Program Files\MyApp.exe"

//every other argument, separated by spaces, is in the array in order
remote.process.argv[1] == "-debug"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!