Alas, quit doesn't behave here as it's supposed to do.
When the script asks Mail to quit, the menu item quit of the application switch to gray (disabled) but the script stops.
No process is reported as working in Activity Monitor but the only way to really quit is force quit.
I guess that something is weird but I don't know if it is the app, the system or an extraneous component.
What I'm sure of is that this behavior surfaced just after the update to 10.8.1 (used in French).
--{SCRIPT]
# Get four localized strings
set p2pane to ((path to library folder from system domain as text) & "PreferencePanes:StartupDisk.prefPane") as alias
set btn1 to localized string "CANCEL" in bundle p2pane
set btn2 to localized string "RESTART" in bundle p2pane
set btn3 to localized string "SHUTDOWN" in bundle p2pane
set prompt to localized string "RESTART?" in bundle p2pane
if (system attribute "sysv") = 4225 then
# here we are running 10.8.1
tell application "System Events"
set visible of processes to true
set processusVisibles to name of processes whose visible is true and name is not "Finder" and name is not "Applescript Editor"
end tell
repeat with unProcessus in processusVisibles
do shell script "killall " & (quoted form of unProcessus)
end repeat
else
tell application "System Events"
set visible of processes to true
set processusVisibles to bundle identifier of processes whose visible is true and name is not "Finder" and name is not "Applescript Editor"
end tell
repeat with unProcessus in processusVisibles
tell application id unProcessus to quit
end repeat
end if
set queFaire to display dialog prompt buttons {btn1, btn2, btn3} default button 3
if button returned of queFaire is btn3 then
tell application "System Events" to shut down
else if button returned of queFaire is btn2 then
tell application "System Events" to restart
end if
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) jeudi 6 septembre 2012 15:44:34