Have OSX Launch Applicaiton on restart? This may seem like a odd question since most people would want to know how to start a program on boot. I was wondering if there is a way to have OSX launch an application when the restart button is pressed from the apple menu.
It's doable with a reboot proxy, i.e. you'd rename /sbin/reboot, e.g. sudo mv /sbin/reboot /sbin/reboot.ori, and then create a reboot symlink to the /sbin/reboot_proxy bash script that has the command(s) you what to execute before the reboot and then lastly it executes /sbin/reboot.ori.  I actually have this setup on my Mac running OS X 10.8.5 and it works well.  I'm trapping both reboot and shutdown commands. Which are what's run when clicking the Apple menu > Reboot... and or Shut Down... commands.


Note: It's best to have a second bash script to toggle the state of the original file and the proxy bash script as it has to be set back before OS X updates are done that will touch the file(s).


This is the code in my shutdown_proxy bash script that has a symbolic link for both the reboot and shutdown commands after the original were renamed with a .ori extension.  Feel free to adapt it for your use.

Contents of reboot_proxy 

#!/bin/bash

_name="$0";
echo "Reboot Proxy Executing..."

# Place command(s) to execute before reboot directly below this comment:


_command="$_name.ori"
echo "Executing $_command $@..."

"$_command" "$@"


Let me add that from a security standpoint there are those that would argue this is a bad thing to do and I'd say to some extent that's true under the right conditions however since I'm the only one that has ever and will ever touch my Mac and I have several layers of security running beyond the built-ins, I personally have no issue using such a method.