這個指令碼會刪除Dock程式預設的自動添加App Store.app表徵圖到使用者Dock上的行為。
具體的操作使用參見指令碼說明。
#!/bin/bash<br /># ------------------------------------------------------------------------<br /># Removing App Store icon from User's Dock:<br />#<br /># Script name: RmAppStoreIcon.sh<br />#<br /># Copy Right:<br /># Copy Right 2011 Tony Liu, all right reserved.<br />#<br /># Description:<br /># If you don't want end user to have App Store icon on their Dock, this is right for you.<br /># Why bother this? because most enterprise environment policies don't like people purchasing<br /># stuff online, ie App Store.<br />#<br /># The system wide Dock icon is stored in the plist file:<br /># /System/Library/CoreServices/Dock.app/Contents/Resources/English.lproj/default.plist<br />#<br /># This script needs PlistBuddy command line tools installed on your OS, which is included in most<br /># of Apple packages. it's easy to be found anyway. Or pack commands in a installation package.<br />#<br /># You can use the following command to remove it:<br /># plistbuddy -c "delete :persistent-apps:0" /System/Library/CoreServices/Dock.app/Contents/Resources/English.lproj/default.plist<br />#<br /># For newly login users, Dock.app will put the App Store icon on user's Dock automatically.<br /># For logged in users, the App Store icon is already sits on their Dock.<br /># To remove for all users, a the best practise example likes this:<br /># removeSysAppStoreIcon<br /># removeAllUserAppStoreIcon<br />#<br /># Another approch: removing the "App Store.app" from /Applications folder totally.<br />#<br /># For some situation, you may want end users to use it at home, but not in enterprise environment.<br /># do the restriction within MCX or Workgroup Manager.<br />#<br /># History:<br /># Initial: Tony 2011-06-20<br />#<br /># ------------------------------------------------------------------------<br /># How to use these commands:<br /># call removeAllUserAppStoreIcon to remove for all users<br /># call removeUserAppStoreIcon USERNAME, to remove USERNAME user's App Store icon.<br /># call removeSysAppStoreIcon to remove from system wide.<br /># ------------------------------------------------------------------------</p><p>function RemoveAppStore<br />{<br />defaultPlist="$1"<br />#currentSet=`plistbuddy -c "print :persistent-apps" $defaultPlist`<br />#currentSet=${currentSet/////":"}</p><p>index=0<br />while [ true ]<br />do<br />curAppIcon=`plistbuddy -c "print :persistent-apps:$index" $defaultPlist`<br />echo "$index" "$curAppIcon"<br />if [ -n "$curAppIcon" ]; then<br />isAppStore=`echo $curAppIcon | grep "App Store"`<br />if [ -n "$isAppStore" ]; then<br />sudo plistbuddy -c "delete :persistent-apps:$index" $defaultPlist<br />echo "Deleted App Store @ $index"<br />break<br />else<br />let index=index+1<br />fi<br />else<br />break<br />fi<br />done<br />}<br />function removeSysAppStoreIcon<br />{<br /> RemoveAppStore "/System/Library/CoreServices/Dock.app/Contents/Resources/English.lproj/default.plist"<br />}<br />function removeUserAppStoreIcon<br />{<br /> RemoveAppStore "/Users/$1/Library/Preferences/com.apple.Dock.plist"<br />}<br />function removeAllUserAppStoreIcon<br />{<br /> for aUser in `ls -1 /Users`<br /> do<br /> removeUserAppStoreIcon "$aUser"<br /> done<br />}<br />RemoveAppStore "/Users/schooladmin/Desktop/default.plist"<br />exit 0
Tony liu, June 2011
Calgary