how to quickly reboot from OSX to Windows and back
Note: This does not work on systems with System Integrity Protection enabled
Write a shell script that does this
#!/bin/sh
# tell OSX to change the boot disk
# nextonly just for the next time - without the default would be Windows
/usr/sbin/bless -mount /Volumes/BOOTCAMP --setBoot --nextonly
# reboot
/sbin/shutdown -r now
This can be called from a terminal window
sudo bootcamp
The use Automator to call this via an apple script and save as an application
on run {input, parameters}
do shell script "/Users/mark/bin/bootcamp" with administrator privileges
return input
end run
Another way to get from OS X to Windows quickly is to use Bootchamp, which adds a menu bar item like this:
For my Windows-booting needs Bootchamp has worked well.
(I learned about it from a similar question on Super User I once asked.)
Hold ⌥ while booting, you'll get a prompt to choose which OS / drive you want to boot from!
Here is an Automator workflow I wrote to accomplish rebooting to Bootcamp automatically:
https://github.com/ryanmcginnis/Restart-to-Bootcamp
As of El Capitan, it is no longer possible to programmatically set the startup disk, even with SIP disabled.
It seems this script from SuperUser handles the closing of open windows (and stopping the scheduled restart if user presses 'cancel'):
do shell script "hdiutil unmount /Volumes/<Windows_Partition> -quiet"
do shell script "bless -device /dev/disk0s3 -legacy -setBoot -nextonly" with administrator privileges
tell application "Finder" to restart