I have two partitions on my mac: Mac OS X and Windows 7. I constantly switch between them so I started looking for a way to restart automatically into the other partition (without having to press Alt on restart). For Windows it is easy because the Boot Camp utilities provided by Apple has a quick menu for that. On Mac, though, I had to search and I found this code in Apple Script:
do shell script "bless --mount /Volumes/Windows/ --setBoot" with administrator privileges
do shell script "shutdown -r now" with administrator privileges
The problem is this doesn't work. When it restarts after running this script it goes to the Mac partition, instead of Windows.
The good thing about AppleScript is that I can save it into an app and run if from the Dock, but so far it hasn't worked. Any ideas?
For the bless command you should use an -legacy option as well do the command would be
do shell script "bless --mount /Volumes/BOOTCAMP/ --setBoot --legacy" with administrator privileges
As you can see my windows partition is named BOOTCAMP, fill in the exact path to the mounted windows volume. If the volume isn't mounted bless command won't work either.
I wouldn't use the shutdown command from the command line. It won't give you the ability to save unsaved documents. Use system events instead
tell application "System Events" to shut down