Hi everybody, been scripting for the last 10 years now and it seems I can’t figure out (don’t laugh please) how to make my computer shut down when some files are already open and unsaved. I use an Entourage rule to trigger the following script:
tell application “Finder”
activate
shut down
end tell
property bl_ls : {"loginwindow", "SystemUIServer", "System Events", "UniversalAccess", "Finder", "Dock"}
--collect running apps
tell application "System events"
set quit_ls to name of every application process ¬
whose file type is "APPL"
end tell
--quit applications
repeat with i in quit_ls
set aProcess to i as text
if aProcess is not in bl_ls then
try
quit application aProcess
on error --force quit
try
do shell script ("killall " & aProcess as text)
end try
end try
end if
end repeat
--finally, shut down
tell application "System Events" to shut down