2010-10-13 86 views
0

在Mac中,我想要使用Shell腳本從登錄項目中刪除應用程序。如何使用shell腳本從登錄項目中刪除項目

我嘗試下面的代碼,但沒有工作..

defaults write loginwindow AutoLaunchedApplicationDictionary -array-remove path "/Applications/myApp.app" 

但它給錯誤 「意外的說法 - 路徑;離開默認不變」

問候, Dhanaraj

回答

0

試試:

defaults write /Library/Preferences/loginwindow AutoLaunchedApplicationDictionary -array-remove '{ "Path" = "/Applications/myApp.app" }'

欲瞭解更多信息請查看以下鏈接:http://mattdanger.net/tag/mac-os-x/

+0

不爲我 – seriyPS 2012-02-17 17:33:22

+0

作品你得到任何錯誤訊息? – 2012-02-26 20:57:38

+0

'$默認寫登錄窗口AutoLaunchedApplicationDictionary -array-刪除 '{ 「路徑」= 「/Applications/my_app.app」}' 2012-02-28 16:06:30.955的默認值[505:707]意外的參數{ 「路徑」 =「/Applications/my_app.app」};保持默認值不變 – seriyPS 2012-02-28 13:07:37

1

-array-remove不存在......我解決這個問題是這樣的:

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