Re: Using AS to logout
Re: Using AS to logout
- Subject: Re: Using AS to logout
- From: Christopher Nebel <email@hidden>
- Date: Tue, 3 May 2005 16:20:56 -0700
On May 3, 2005, at 3:10 PM, Mark J. Reed wrote:
On 5/3/05, Francois Houle <email@hidden> wrote:
I'm looking to include a
Tell application "System Events"
log out
end tell
staement in a script... I'd like to know if there is a way to
bypass the confirmation dialog that pops up asking if you real
want to logout... Basically so that when i say logut, it simply
does logout without asking anything... Is it even possible in AS ?
Well, you could always just kill the loginwindow process. I'm sure
there's a better way, but this might do the trick - no guarantees
since I'm away from my Mac at the moment:
do shell script "ps x | awk '(tolower($0) ~ /loginwindow/) {print
$1}' | xargs kill"
You know, I really wish people would stop recommending this sort of
thing. This is what we call the "nuclear option" -- it will
immediately terminate all user processes, giving them no chance to do
any sort of cleanup.
The answer to the original question is "sort of". All the supported
ways of logging out will try to quit all running applications first,
so it's still possible for an application to refuse to quit (either
on its own, or because you pressed a "cancel" button) and therefore
prevent the logout. However, you can avoid the initial confirmation
("do you really want to log out"), but you have to cheat a bit.
While System Events is the scripting front end to all the "Power
Suite" commands, the application that actually handles them is
loginwindow. In addition, there's a fifth command that's not in the
scripting dictionary; «event aevtrlgo», short for "really log out".
It's the same as "log out", but doesn't let you confirm first.
Therefore,
tell application "loginwindow" to «event aevtrlgo»
...should do what you want, or as close to it as possible. Now that
I think about it, "log out" ought to use that command, not the one
that prompts first. I'll file a bug.
--Chris Nebel
AppleScript and Automator Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden