Logout user script

The Apple event is the most robust way to do it (but it can still be blocked by a stuck app).

Entering the special characters is tricky... here's a block you can use in a script or via ARD.

osascript -e 'ignoring application responses' -e 'tell application "loginwindow" to «event aevtrlgo»' -e end

The « and » characters are typed by option-\ and shift-option-\ respectively.


The rlgo (kAEReallyLogOut) Apple event logs out without showing a confirmation dialog:

tell application "loginwindow" to «event aevtrlgo»

tell application "System Events" to log out sends loginwindow a logo (kAELogOut) Apple event. The Apple events are listed in AERegistry.h.