Dan Stutzman

How to automatically restart a Mac app after reboot

Published 2011-05-04

Many Mac users probably know you can go to System Preferences -> Accounts -> Login Items and click the plus (+) button to have a certain application start itself automatically whenever the user logs in. But how can you accomplish this programmatically?

A Stack Overflow post gives some API methods to call, but I wanted something quick and dirty that I could run from a shell script. I settled on running /usr/bin/osascript add-login.applescript The file add-login.applescript is the copied from a helpful AppleScript site:

tell application "System Events"
           get the properties of every login item
           make new login item at end of login items with properties {path:"/Applications/YourAppNameHere.app", hidden:false}
          end tell

It even looks like you can run this multiple times without adding more login items.