Advertisement
applehelpwriter

logout all other users

Apr 30th, 2016
1,090
0
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
  4.  
  5. # For more info see
  6. # http://applehelpwriter.com/2016/04/30/how-to-log-out-another-user-without-logging-in/
  7.  
  8. set thisUser to do shell script "whoami"
  9. set usrList to paragraphs of (do shell script "ps caux -o args | grep loginwindow")
  10.  
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement