user-startup
Automatically run commands when the user logs in. Used in hotel and stop-server.
- No admin privileges required
- Cross-platform (OS X, Linux and Windows)
Install
npm install user-startup --save
Example
const startup = const nodePath = processexecPathconst args = '/some/path/app.js'const out = '/some/path/out.log' // Creates startup script and spawns processstartup // Removes startup scriptstartup
Note: you should check that root isn't running this code to avoid startup scripts being created in root's home directory. Use sudo-block or is-root.
API
add(id, cmd[, args[, out]])
id <String>
idcmd <String>
commandargs <Array>
optional list of string argumentsout <String>
optional path to output file (directory needs to exist before)
Creates startup script.
create(id, cmd[, args[, out]])
Creates a startup script and spawns process.
remove(id)
Removes startup script.
dir
Returns startup script directory.
getFile(id)
Returns startup script path.
How it works
- On OS X, it creates a
plist
file in~/Library/LaunchAgents
- On Linux, it creates a
desktop
file in~/.config/autostart
- On Windows, it creates a
vbs
script inAppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
License
MIT - Typicode