Login Items List

This is an AppleScript to give you control over your Mac user login items. They are the items displayed when you open System Preferences>Users & Groups>Login items (your user must be selected at the left in the Users & Groups prefpane).

Copy and paste the text on the right side in the text block below into an empty document window of Script Editor or AppleScript Editor on your Mac system. This script has worked since Mac OS X 10.3 Panther and I still use it in MacOS 10.12.5 Sierra.

Run the script.

Select one or more login items from the list and click OK.

Choose whether to reveal the login item in the Finder or to remove it from the current login items. (Tip: try revealing one or more login items first and if you don’t really want them removed after you test removing, just open login items in the Users & Groups System prefpane and drag them back in there!)

tell application "System Events"
activate
set loginItems to name of every login item
choose from list loginItems with multiple selections allowed
end tell
set theResult to result
if theResult is false then
tell me to quit
else
activate
if (count of items of theResult) is not 0 then
if (count of items of theResult) is 1 then
display dialog "What do you want to do with" & ¬
space & every item of theResult & "?" buttons ¬
{"Cancel", "Reveal it", "Remove it"}
else
display dialog "What do you want to do with
the selected login items?" buttons ¬
{"Cancel", "Reveal them", "Remove them"}
end if
if button returned of result contains "Remove" then
repeat with i in theResult
tell application "System Events"
delete (every login item whose name is (i as text))
end tell
end repeat
set this_user to (do shell script "id -un")
do shell script "killall -u" & space & this_user & space & "cfprefsd"
do shell script "killall -u root cfprefsd" with administrator privileges
else if button returned of result contains "Reveal" then
repeat with i in theResult
tell application "System Events"
set loginitempaths to (get the path of every login item)
repeat with loginitempath in loginitempaths
if loginitempath contains (i as text) then
set g to (loginitempath as text)
end if
end repeat
end tell
set actual_Path to POSIX file g
tell application "Finder"
activate
reveal (actual_Path as text)
end tell
end repeat
end if
end if
end if
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s