Q:

How do I start programs automatically when Mac OS X boots up? Specifically VMWare Fusion's vmrun to start VMs

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!)

A:

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.

A:

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):

When Mac OS X boots the VM starts up in the background. This also works for more than one VM.
If at any time the VM crashes it will be restarted immediately.
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).
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.

