3

I frequently reboot into Windows on a bootcamp partition in my Mac Pro (e2008) (Mac Os X 10.5.6). Because I like to use the time it takes to reboot for other things instead of just sitting around I'd like to write/execute a simple applescript that would basically do:

  1. Quit all running user applications
  2. Then*—after the apps have been quit properly—*restart to my bootcamp partition

Part 2 I have been using for a little while now with a script I found online that is as follows:

do shell script "bless -mount /Volumes/WinVista/ -legacy -setBoot -nextonly" with 
administrator privileges
do shell script "shutdown -r now" with administrator privileges

This works great except that if applications are open they are not properly shutdown (basically they are being 'force quit') so I would like to have the script shutdown apps first then execute the reboot.

I have found a similar question on Stack Overflow but since my understanding of AppleScript is virtually none existent I don't know how I could combine this: (Quit All Applications using Applescript?) with the script that does the reboot.

Is this possible? If so I would appreciate any advice/help/scripts you can throw at me.

Also I have virtually no experience with AppleScripting all I have done so far was copy/pasting what I had found online, just in case that matters.

Thank you for reading.

Jannis

Community
  • 1
  • 1
Jannis
  • 17,025
  • 18
  • 62
  • 75

1 Answers1

6

try using

tell application "Finder" to restart

this try to quit every application, while prompting for saves, and then reboot the computer

cobbal
  • 69,903
  • 20
  • 143
  • 156
  • +1 I've been using the same script that Jannis posted, but this is a much better way of doing it. I just tried it out, and it works like a charm. Thanks! – e.James Jul 05 '09 at 02:47
  • Thanks for the reply, but how will I automatically tell it to boot into my Windows partitions so I don't have to hold down the ALT key while booting to get to the bootmanager? – Jannis Jul 06 '09 at 04:10
  • Should this be the script to quit all apps + restart directly to Windows? do shell script "bless -mount /Volumes/WinVista/ -legacy -setBoot -nextonly" with administrator privileges tell application "Finder" to restart – Jannis Jul 06 '09 at 04:13
  • yep, the first part of your script looks good (I think.) It was only the second part that you needed to change – cobbal Jul 06 '09 at 04:17
  • Thanks again, your line works brilliantly! This is what I used ultimately: display dialog "This script will quit all running application and restart this Mac directly to Windows. Do you want to continue?" with icon 2 with title "WARNING: This computer is about to be restarted!" do shell script "bless -mount /Volumes/WinVista/ -legacy -setBoot -nextonly" password "xxxxxx" with administrator privileges tell application "Finder" to restart – Jannis Jul 06 '09 at 07:57
  • **Sidenote**: A close derivative of this is useful for OS X-targeted shell scripts: `osascript -e 'tell application "Finder" to restart'` – Slipp D. Thompson Apr 13 '13 at 20:53