Automatically run commands when the user logs in. Used in hotel and stop-server.
- Cross-platform (OS X, Linux and Windows)
- No admin privileges required
npm install user-startup --save
var startup = require('user-startup')
var nodePath = process.execPath
var args = ['/some/path/app.js']
var out = '/some/path/out.log'
// Create startup script and spawn process
startup.create('my-script', nodePath, args, out)
// Remove startup script
startup.remove('my-script')
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, is-root or similar modules.
add(id, cmd, args, out)
Creates startup script.
remove(id)
Removes startup script.
create(id, cmd, args, out)
Creates a startup script and spawns process.
dir
Returns startup script directory.
getFile(id)
Returns startup script path.
- 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
MIT - Typicode