Re: Quit All Applications
Re: Quit All Applications
- Subject: Re: Quit All Applications
- From: Nigel Garvey <email@hidden>
- Date: Wed, 24 Jan 2001 11:30:41 +0000
"Marc K. Myers" wrote on Wed, 24 Jan 2001 00:30:40 -0500:
[Script snipped]
>
>
This script, as written, will send a "quit" to the Finder for each app
>
that's running, quitting the Finder and not the apps. You can't put a
>
"quit" inside a tell to the Finder. You have to put it in a separate
>
handler:
>
>
tell application "Finder"
>
.................
>
tell me to doQuit(a)
>
.................
>
end tell
>
>
on doQuit(theApp)
>
tell application theApp to quit
>
end doQuit
... or, of course, only use the Finder to identify the apps. This version
also preserves background processes:
try
tell the application "Finder"
get (the name of every process whose file type is "APPL") as list
end tell
repeat with thisName in the result
tell application thisName to quit
end repeat
on error
end try
The 'try' block is in case there are no applications open (trying to get
their names produces an error) and the 'as list' is in case there's only
one (the result is a simple string). You don't have to worry about
excluding the Finder itself as it doesn't appear in the processes.
NG