I am following the example for requestSingleInstanceLock() in the Electron's documentation. For some reason the second instance's command line arguments seem corrupted if the arguments have quoted values with spaces inside. The initial process.argv
looks just fine, however the argv
parameter in the second-instance event comes split at the spaces adding additional argument values, all values are transformed to lower case, and somewhat presorted.
Is there a way to disable this processing, and eventually pass/get the command line of the second instance as is?
NOTE: I have used app.makeSingleInstance()
in previous Electron versions, however this API has been removed.
Here's an excerpt from the test app I use:
console.log(process.argv);
if (!app.requestSingleInstanceLock()) {
app.exit();
}
app.on('second-instance', (event, argv, workingDirectory) => {
console.log('second-instance', argv);
});
Here's the result:
C:\electron-app-win32-x64>electron-app.exe "/Arg1 Value1" "/Arg2 Value2"
C:\electron-app-win32-x64>
[
'C:\\electron-app-win32-x64\\electron-app.exe',
'/Arg1 Value1',
'/Arg2 Value2'
]
second-instance [ <--- from the same command in another console
'electron-app.exe',
'/arg1',
'/arg2',
'--allow-file-access-from-files',
'--original-process-start-time=13232862957593703',
'value1',
'value2'
]