In Mac, I want to remove an application from the login items using Shell script.
I tried following code, but didn't 开发者_C百科work..
defaults write loginwindow AutoLaunchedApplicationDictionary -array-remove path "/Applications/myApp.app"
But it is giving error "Unexpected argument -path; leaving defaults unchanged"
Regards, Dhanaraj
-array-remove
does not exist… I solved this issue this way:
ln=`/usr/bin/defaults read /Library/Preferences/loginwindow AutoLaunchedApplicationDictionary | grep "Path =" | sed -n '/myApp.app/='`
if [ "$ln" != "" ]
then
echo $ln | /usr/bin/sort -nr | while read k
do
/usr/libexec/PlistBuddy -c "Delete :AutoLaunchedApplicationDictionary:$(($k-1)) dict" /Library/Preferences/loginwindow.plist
done
fi
精彩评论