Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I configure programs to run automatically when (after) Mac OS X boots up?

Specifically I am trying to get VMWare VMs to start automatically after an OS X reboot but running any (non-graphical) program would be useful.

(Note that vmrun starts VMware VMs in the background and the Fusion GUI can pick them up later. So this is not about starting the VM on the desktop after I log in!)

share|improve this question

3 Answers 3

On a Mac, if you want to run a script or application on boot (not on login), add it to /System/Library/StartupItems. In the case of vmrun, I would write a shell script to set the path correctly (to include the VMWare Fusion directory) and start the particular VMs you wish to run.)

If you prefer to run it on login, you can add items to the 'Login Items' under the users section of the System Preferences.

share|improve this answer
    
Don't items in StartupItems have to be in a special format? Can I really just add a shell script and see it executed at/after booting? –  Andrew J. Brehm Jan 28 '10 at 10:03
    
Sorry, you do -- but the format is really simple. Instructions at osxfaq.com/Tutorials/LearningCenter/HowTo/Startup/index.ws are old but I believe still correct. –  Jon Lasser Jan 28 '10 at 16:10
3  
Apparently /System/Library/StartupItems is no longer used (and /System should be used by Apple only anyway). Instead /Library/LaunchDeamons is used. –  Andrew J. Brehm Jan 29 '10 at 10:54
    
@AndrewJ.Brehm "/System should be used by Apple only" - not if you're a Super User :v –  Luke Madhanga Sep 4 at 19:19
up vote 1 down vote accepted

I tried a few methods and got the weirdest results. This is what finally worked:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.example.myvmname</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Library/Application Support/VMware Fusion/vmrun</string>
        <string>start</string>
        <string>pathtovirtualmachinevmxfile.vmx</string>
        <string>nogui</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>UserName</key>
    <string>myusername</string>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

I created a file com.example.vmname.plist containing the above in /Library/LaunchDeamons and made sure its owner:group was root:wheel. the Apple developer tools provide an excellent editor for plist XML files.

This produces the following behaviour, which is ideal for my environment (I have a eight-core Mac Pro with 8 GB of memory and can afford to run several VMs in the background instead of suspending them or shutting them down):

  1. When Mac OS X boots the VM starts up in the background. This also works for more than one VM.

  2. If at any time the VM crashes it will be restarted immediately.

  3. The same applies when the VM is being shut down or stopped unless done from the Fusion GUI (the latter behaviour allows for editing VM settings).

  4. When Mac OS X shuts down, the VM suddenly stops. I have to find a way to shut them down more gracefully before a system reboot.

share|improve this answer

These solutions are way overcomplicated. By far the easiest way is to go to System Preferences ->Users & Groups->Login items tab and click the plus and select the app you want to start.

Also in System Preferences ->Users & Groups you can select Login Options and select your user for automatic login of that user. THERE IS NO SECURITY RISK TO THIS UNLESS YOU GIVE OTHER PEOPLE PHYSICAL ACCESS TO YOUR MACHINE!

Anyone with physical access to your machine can boot off an external drive (or various other methods of bypassing your login password) and have access to all the files on your hard disk. The correct answer to your computer's security is not to have your computer nag YOU to enter your own password every time you walk up to it, instead it is to lock your room! Has the added benefit of not allowing your 3 year old to rip out the keys on your keyboard, spill orange juice on your mac pro, and other such things.

So remember, login passwords are only for shared work areas/environments where your computer is somewhere everyone else can walk up to and use - something you should never do with your home PC in my opinion. If you have proper physical security, the login password is just a waste of your time and should be disabled, it provides almost no security at all.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.