OSX指令碼:禁止系統自動添加AppStore表徵圖到使用者Dock上

來源:互聯網
上載者:User

這個指令碼會刪除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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.