Skip to content

Instantly share code, notes, and snippets.

@jwhitley
Forked from robjwells/Restart in Windows.applescript
Last active November 10, 2016 16:23
Show Gist options
  • Save jwhitley/8377268 to your computer and use it in GitHub Desktop.
Save jwhitley/8377268 to your computer and use it in GitHub Desktop.
set deviceID to (do shell script "diskutil list | awk '/YourBootcampPartition/ {print $NF}'")
do shell script "sudo bless -device /dev/" & deviceID & " -legacy -setBoot -nextonly"
tell application "Finder" to restart
@jwhitley
Copy link
Author

In order to use this script without having to enter your password, you must have a line like the following in your /etc/sudoers file:

myuser ALL=(root) NOPASSWD: /usr/sbin/bless

where myuser must be replaced with your short user name, which you can find by running the command whoami in Terminal.app. I recommend reading the sudoers(5) manpage (man sudoers in terminal, or search the web) if you want to learn more about what that line does and sudo configuration, though I suspect that page will be rather inscrutable if you don't have solid basic Unix command line familiarity.

@robjwells
Copy link

That’s a neat solution, nice work John.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment