I'm using the app.setLoginItemSettings(settings)
for auto launching the app when system starts. The example given in the Electron API doc page is for Windows I believe. When adding the following in the Electron main.js
, the app auto launches just fine but also shows an additional window that says the following which I don't want:
To run a local app, execute the following on the mand line:
Users/abc/Documents/Repositories/app/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron path-to-app
main.js
const appFolder = path.dirname(process.execPath)
const updateExe = path.resolve(appFolder, '..', 'Update.exe')
const exeName = path.basename(process.execPath)
import { app } from "electron";
app.on("ready", async() => {
app.setLoginItemSettings({
openAtLogin: true,
path: updateExe,
args: [
'--processStart', `"${exeName}"`,
'--process-start-args', `"--hidden"`
]
});
});
I also tried with the following path
but that also didn't work:
const appFolder = path.dirname(process.execPath)
const updateExe = path.resolve(appFolder, '..', 'Update.exe')
const exeName = path.basename(process.execPath)
import { app } from "electron";
app.on("ready", async() => {
app.setLoginItemSettings({
openAtLogin: true,
path: "/Applications/MyApp.app",
args: [
'--processStart', `"${exeName}"`,
'--process-start-args', `"--hidden"`
]
});
});
In addition, also tried with the Electron Root Path package but still no luck:
const appFolder = path.dirname(process.execPath)
const updateExe = path.resolve(appFolder, '..', 'Update.exe')
const exeName = path.basename(process.execPath)
import { app } from "electron";
import { rootPath } from "electron-root-path";
app.on("ready", async() => {
app.setLoginItemSettings({
openAtLogin: true,
path: rootPath,
args: [
'--processStart', `"${exeName}"`,
'--process-start-args', `"--hidden"`
]
});
});
Last but not least