Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Boot to Windows partition quickly System
I wanted a quick way to boot once to Windows. Typically I reboot and hold the Option key to select an alternate startup disk. I've decided that I will upgrade the video card on my Mac Pro to an ATI 6870. Since there is currently no way to flash the card to EFI I will not be able to see the boot drive options when I boot holding down Option.

And I don't want to change the boot drive every time I want to boot to Windows. When I'm done with Windows I like to just reboot and leave knowing the rest will just happen.

I came up with this little script:
#! /bin/bash
diskutil list > /tmp/connecteddrives.txt
INPUT=/tmp/connecteddrives.txt
driveid1=$(grep Microsoft "${INPUT}" | awk '{print $8}')
echo $driveid1
sudo /usr/sbin/bless --device /dev/$driveid1 --setBoot --legacy --nextonly
rm /tmp/connecteddrives.txt
exit 0
You may need to change the awk '{print $8}' command if you have spaces in your Boot Camp volume name.

To find out if it will work simply type this into terminal:

diskutil list|grep Microsoft|awk '{print $8}'

If you get something along the lines of disk#s# it works. If not change the number 8 up or down by one till you find it. Then modify the script accordingly, make it executable and enjoy.

[crarko adds: I don't use Boot Camp, so I haven't tested this one.]
    •    
  • Currently 3.50 / 5
  You rated: 2 / 5 (6 votes cast)
 
[9,243 views]  

Boot to Windows partition quickly | 14 comments | Create New Account
Click here to return to the 'Boot to Windows partition quickly' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Boot to Windows partition quickly
Authored by: corndoggyrob on Sep 27, '11 08:06:09AM

This is a great tip, but have you ever tried BootChamp? It runs in the menubar. Quickly reboot to Windows via a menubar click.

http://www.macupdate.com/app/mac/28468/bootchamp



[ Reply to This | # ]
Boot to Windows partition quickly
Authored by: tempel on Sep 27, '11 08:52:04AM

My menu bar is already full enough, so I appreciate this little script. Thanks!



[ Reply to This | # ]
Boot to Windows partition quickly
Authored by: BenGleason on Sep 27, '11 09:52:47AM

I used BootChamp until I upgraded to Lion. It doesn't work under Lion



[ Reply to This | # ]
How do you use this?
Authored by: Spliff on Sep 27, '11 11:32:02AM

Unix noob here. How do I actually use and launch this script?



[ Reply to This | # ]
How do you use this?
Authored by: MVasilakis on Sep 28, '11 01:33:14PM

get yourself a good text editor. I recommend TextWrangler (free):
http://www.barebones.com/products/textwrangler/
(Also available in the app store)

Then paste the code and save it to your desktop as bootcamp.command
Open terminal and type:

cd ~/Desktop
chmod a+x ~/Desktop/bootcamp.command


Double click to run. You will need to enter your admin password.

Reminder:
Copy and paste this into terminal to make sure you get the requite result as described in my original post!
diskutil list|grep Microsoft|awk '{print $8}'



[ Reply to This | # ]
Boot to Windows partition quickly
Authored by: urandrod on Sep 27, '11 12:38:17PM

I'm looking for a solution in a lab environment that will always show the boot screen upon startup without holding the option key down. That way, any newbie who restarts the computer will get the boot option menu and must choose an operating system.

Can anyone help with that?



[ Reply to This | # ]
Boot to Windows partition quickly
Authored by: Anonymous on Sep 28, '11 09:06:26AM

This might work for you:
http://refit.sourceforge.net/



[ Reply to This | # ]
Boot to Windows partition quickly
Authored by: mkaz on Sep 27, '11 03:20:17PM

This also works just using applescript. replace login_password with your login password.
Also make sure the path to BOOTCAMP is correct (it should be).

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



[ Reply to This | # ]
Re: Boot to Windows partition quickly
Authored by: Uncle Asad on Sep 27, '11 10:35:57PM
Depending on which side of the speed vs. security continuum you fall, you can omit the password "login_password" portion of the do shell script commands, and AppleScript will prompt you for your password, rather than requiring you to leave it in plain-text in the script…

[ Reply to This | # ]
Re: Boot to Windows partition quickly
Authored by: everkleer80 on Sep 30, '11 08:26:53AM

It's also fairly easy to pull the password from your keychain if you don't want to have to enter it each time but you don't want to store it in plain text either. I don't have access to the details right now, but using Keychain Scripting it was easy for me, as an Applescript noob, to figure it out. If anyone wants help using Keychain Scripting, just reply to this and I will post an example when I have time.



[ Reply to This | # ]
Re: Boot to Windows partition quickly
Authored by: simondorfman on Sep 30, '11 11:44:09AM

Yes, please do post that code when you get a chance. Thanks!



[ Reply to This | # ]
Re: Boot to Windows partition quickly
Authored by: everkleer80 on Oct 06, '11 04:09:09PM

Well, turns out Apple has removed Keychain Scripting in Lion, but Daniel Jalkut of Red Sweater software has developed a scriptable alternative that you can download.

Here is my simple example of using Keychain Scripting: (I imagine the s/w I linked to works in a similar way)

tell application "keychain scripting"
set thePW to the password of first key of current keychain whose name is "AdminPassword"
end tell

Then I just used Keychain Access to create an item named "AdminPassword" in my default keychain.



[ Reply to This | # ]
Boot to Windows partition quickly
Authored by: manxman on Sep 28, '11 02:14:43PM

I can't believe I've actually read a post on here headed 'Boot to Windows Partition Quickly', and we're expected to feel the need to do so. The irony is excruciating.
What is the Mac world coming to?
That is all.

Edited on Sep 28, '11 02:16:03PM by manxman



[ Reply to This | # ]
Boot to Windows partition quickly
Authored by: artcarney on Oct 27, '11 10:50:37PM

I'm into ham radio and while there are some exciting new apps for that I still find the best software for what I want to do is on Windows and that software doesn't even begin to work with Wine/Wine Bottler, VirtualBox and the others (USB issues) so I found myself installing Win7 Pro on a 50 gig Bootcamp partition.

In the past I tried downloading BootChamp but I discovered it didn't play with Lion so I tried this script and it's works perfectly!

Well, actually I tried living without it at first but it always seemed I would get distracted and forget to hold down the opt/alt key at boot and back into OS X I would go instead of Win7.

So Thanks for the script! It saves an old guy like me a couple of unnecessary reboots to get to my Win7 setup so I can play radio!



[ Reply to This | # ]