Currently I need to get command line arguments from an Electron application. So if you start the application with command line arguments, I need to use the arguments within the renderer process (a webview to be specific.)
This works fine when opening the application for the first time (using onload), but I'm having issues getting this to work when the application is already running and the user tries to reopen the app from cmd with args.
Currently, I'm using:
let closeDupeApp = app.makeSingleInstance(function(commandLine, workingDirectory) {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
}
});
To prevent a second window from opening. However, I need the commandLine arguments and I need to send them to the renderer process.
Is there a way to do this?
process. The property name isargv. You can readprocess.argvanytime to get the relevant data.