title: Electron app auto launch shows an additional window due to incorrect app path
body: <p>I'm using the <code>app.setLoginItemSettings(settings)</code> for auto launching the app when system starts. The example given in the <a href="https://www.electronjs.org/docs/api/app#appsetloginitemsettingssettings-macos-windows" rel="nofollow noreferrer">Electron API doc page</a> is for Windows I believe. When adding the following in the Electron <code>main.js</code>, the app <strong>auto launches just fine</strong> but also shows an additional window that says the following which I don't want:</p>
  <pre class="lang-sh prettyprint-override"><code>To run a local app, execute the following on the command line:
  Users/abc/Documents/Repositories/app/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron path-to-app
  </code></pre>
  <p><a href="https://i.stack.imgur.com/BM4L9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BM4L9.png" alt="enter image description here" /></a></p>
  <p><code>main.js</code></p>
  <pre class="lang-js prettyprint-override"><code>const appFolder = path.dirname(process.execPath)
  const updateExe = path.resolve(appFolder, '..', 'Update.exe')
  const exeName = path.basename(process.execPath)
  
  import { app } from &quot;electron&quot;;
  
  app.on(&quot;ready&quot;, async() =&gt; {
    app.setLoginItemSettings({
      openAtLogin: true,
      path: updateExe,
      args: [
        '--processStart', `&quot;${exeName}&quot;`,
        '--process-start-args', `&quot;--hidden&quot;`
      ]
    });
  });
  </code></pre>
  <p>I also tried with the following <code>path</code> but that also didn't work:</p>
  <pre class="lang-js prettyprint-override"><code>const appFolder = path.dirname(process.execPath)
  const updateExe = path.resolve(appFolder, '..', 'Update.exe')
  const exeName = path.basename(process.execPath)
  
  import { app } from &quot;electron&quot;;
  
  app.on(&quot;ready&quot;, async() =&gt; {
    app.setLoginItemSettings({
      openAtLogin: true,
      path: &quot;/Applications/MyApp.app&quot;,
      args: [
        '--processStart', `&quot;${exeName}&quot;`,
        '--process-start-args', `&quot;--hidden&quot;`
      ]
    });
  });
  </code></pre>
  <p>In addition, also tried with the <a href="https://github.com/ganeshrvel/npm-electron-root-path" rel="nofollow noreferrer">Electron Root Path package</a> but still no luck:</p>
  <pre class="lang-js prettyprint-override"><code>const appFolder = path.dirname(process.execPath)
  const updateExe = path.resolve(appFolder, '..', 'Update.exe')
  const exeName = path.basename(process.execPath)
  
  import { app } from &quot;electron&quot;;
  import { rootPath } from &quot;electron-root-path&quot;;
  
  app.on(&quot;ready&quot;, async() =&gt; {
    app.setLoginItemSettings({
      openAtLogin: true,
      path: rootPath,
      args: [
        '--processStart', `&quot;${exeName}&quot;`,
        '--process-start-args', `&quot;--hidden&quot;`
      ]
    });
  });
  </code></pre>
  <p>Last but not least , also tried with the following but still no luck:</p>
  <pre class="lang-js prettyprint-override"><code>const appFolder = path.dirname(process.execPath)
  const updateExe = path.resolve(appFolder, '..', 'Update.exe')
  const exeName = path.basename(process.execPath)
  
  import { app } from &quot;electron&quot;;
  import { rootPath } from &quot;electron-root-path&quot;;
  
  app.on(&quot;ready&quot;, async() =&gt; {
  if (process.platform === &quot;darwin&quot;) {
      app.setLoginItemSettings({
        openAtLogin: true,
        openAsHidden: true,
        path: rootPath
      });
    } else {
      app.setLoginItemSettings({
        openAtLogin: true,
        openAsHidden: true,
        path: updateExe,
        args: [
          &quot;--processStart&quot;,
          `&quot;${exeName}&quot;`,
          &quot;--process-start-args&quot;,
          `&quot;--hidden&quot;`
        ]
      });
    }
  });
  </code></pre>
  <p>I am out of all the ideas I have to make this work. Any help from anyone would be really appreciated :)</p>