Posted on 06-26-2017 05:49 AM
hi -
please could someone help me with a command line or script to find out a user's login items?
and a command line or script to remove an item?
thanks in advanced.
Posted on 06-26-2017 07:38 AM
You could start here...
sudo defaults delete ~/Library/Preferences/com.apple.loginitems [some key] [somestring]
Posted on 06-26-2017 07:42 AM
More specifically, to grab the list of a user's login items, something like this should work:
CurUser=$(ls -l /dev/console | awk '{print $3}')
defaults read /Users/$CurUser/Library/Preferences/com.apple.loginitems.plist | grep Name
On the other hand, AppleScript run in Terminal looks like it can manipulate/read these values better than defaults (because the values are deeply nested within the plist):
# delete login item
osascript -e 'tell application "System Events" to delete login item "itemname"'
# list loginitems
osascript -e 'tell application "System Events" to get the name of every login item'
I pulled those commands from this gist, so give that a once over and see if it works for your needs.
Posted on 06-26-2017 09:56 AM
thank you both. reading from plist seems to work. the applescript is hit or miss. not sure why
Posted on 07-30-2018 09:03 AM
Hi, thnx for the tip but I get, expected end of line but found unknown token, on MacOS 10.13.5
what am I doing wrong
thnx