views:

1633

answers:

1

Hi,

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: (http://stackoverflow.com/questions/495323/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

+3  A: 

try using

tell application "Finder" to restart

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

cobbal
+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
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
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
yep, the first part of your script looks good (I think.) It was only the second part that you needed to change
cobbal
Thanks again, your line works brilliantly!This is what I used ultimately:<START>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 privilegestell application "Finder" to restart<END>
Jannis