logout all other users

applehelpwriter Apr 30th, 2016 (edited) 342 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Applehelpwriter 2016
  2. # This script will log out all other users on the mac
  3. # CAUTION: Any unsaved data in those user accounts will be lost
  5. # For more info see
  6. #
  8. set thisUser to do shell script "whoami"
  9. set usrList to paragraphs of (do shell script "ps caux -o args | grep loginwindow")
  11. repeat with i from 1 to number of items in usrList
  12.     set this_item to item i of usrList
  13.     set thatUser to word 1 of this_item
  14.     if thisUser is not equal to thatUser then
  15.         set theProcessNum to word 2 of this_item
  16.         do shell script "kill -9 " & theProcessNum with administrator privileges
  17.     end if
  18. end repeat
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand