Reboot system into Boot Camp

Sharing and discussing custom actions for LaunchBar
Post Reply
neilio
Posts: 4
Joined: Fri Jun 12, 2009 3:40 pm

Reboot system into Boot Camp

Post by neilio » Mon Jun 15, 2009 4:31 am

I rarely need to boot into Boot Camp, but when I do it's a pain to have to switch the boot disk in System Preferences or I sometimes forget to hold down option at boot to override the start up disk. This script automates this for you by restarting the system into Boot Camp for just the next reboot. Reboots after that will boot back into OS X.

Code: Select all

do shell script "bless --device /dev/disk0s3 -legacy -setBoot -nextonly" with administrator privileges
tell application "System Events"
   restart
end tell


To make sure this script works correctly for you, launch the terminal and type the command

df -k

Look for your Boot Camp volume (it's most likely called "/Volumes/Untitled"). At the beginning of that line there should something lke "/dev/disk0s3. If yours is different than that you'll need to tweak that part of the script above to make it function.

sjk
Wizard
Wizard
Posts: 315
Joined: Thu Sep 13, 2007 9:46 pm
Location: Eugene
Contact:

Re: Reboot system into Boot Camp

Post by sjk » Mon Jun 15, 2009 9:01 pm

Hardcoding device file pathnames isn't recommended because there's a possibility of them changing without being noticed, especially if writing to the device (e.g. with bless). Best if people are aware of that risk, even if it's small.

I don't have a Boot Camp volume to test with, but what could work is to give it a unique name and parse the output from the diskutil status command to find its current device name. Or, parsing df output would be easier presuming the volume is mounted (which it needs to be in your script to bless it).

Post Reply