开发者

How To remove an item from Login Items using shell script

开发者 https://www.devze.com 2023-01-20 00:30 出处:网络
In Mac, I want to remove an application from the login items using Shell script. I tried following code, but didn\'t 开发者_C百科work..

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号