How to Restart in Windows Using a Script

applescriptbootcamprestartscript

I'd like to be able to reboot into the Boot Camp partition without needing to go change the Startup Disk in System Preferences or holding down the Option key at startup.

After reading some stuff on the Internet, I tried these shell commands:

sudo bless --mount /Volumes/BOOTCAMP --setBoot
sudo shutdown -r now

When the system restarted, it sat on the blank gray screen for a while, then booted into Mac OS X. If I go into System Preferences -> Startup Disk, it indicates that BOOTCAMP is the current startup disk.

So, it looks to me like the bless command I used isn't sufficient. Anybody know what I need to do to make this work, or an alternative way to use a shell script or AppleScript to do this?

Best Answer

This works just using applescript. replace login_password with your login password. Also make sure the path to BOOTCAMP is correct (it should be). Save as an application and open it when you want to reboot into BootCamp. This is two lines of code...

do shell script "bless -mount /Volumes/BOOTCAMP/ -legacy -setBoot -nextonly" password "login_password" with administrator privileges

do shell script "shutdown -r now" password "login_password" with administrator privileges