mirror of
https://github.com/electron/electron.git
synced 2026-01-08 23:18:06 -05:00
docs: Update Squirrel Run at Login docs to be modern (#44487)
Update Squirrel Run at Login docs to be modern The current docs for setting up Run at Login use the legacy way that Squirrel does shortcuts. This was replaced by an easier method, let's use that instead
This commit is contained in:
@@ -1302,23 +1302,24 @@ Returns `Object`:
|
||||
Set the app's login item settings.
|
||||
|
||||
To work with Electron's `autoUpdater` on Windows, which uses [Squirrel][Squirrel-Windows],
|
||||
you'll want to set the launch path to Update.exe, and pass arguments that specify your
|
||||
application name. For example:
|
||||
you'll want to set the launch path to your executable's name but a directory up, which is
|
||||
a stub application automatically generated by Squirrel which will automatically launch the
|
||||
latest version.
|
||||
|
||||
``` js
|
||||
const { app } = require('electron')
|
||||
const path = require('node:path')
|
||||
|
||||
const appFolder = path.dirname(process.execPath)
|
||||
const updateExe = path.resolve(appFolder, '..', 'Update.exe')
|
||||
const exeName = path.basename(process.execPath)
|
||||
const ourExeName = path.basename(process.execPath)
|
||||
const stubLauncher = path.resolve(appFolder, '..', ourExeName)
|
||||
|
||||
app.setLoginItemSettings({
|
||||
openAtLogin: true,
|
||||
path: updateExe,
|
||||
path: stubLauncher,
|
||||
args: [
|
||||
'--processStart', `"${exeName}"`,
|
||||
'--process-start-args', '"--hidden"'
|
||||
// You might want to pass a parameter here indicating that this
|
||||
// app was launched via login, but you don't have to
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user