將一下內容保存爲iTunes.scpt
,並運行shell
set question to display dialog "肯定是否刪除 iTunes ?" buttons {"Yes", "No"} default button 1 set answer to button returned of question if answer is equal to "Yes" then do shell script "rm -rf /Applications/iTunes.app" with administrator privileges display dialog "iTunes 已刪除" buttons {"OK"} set theDMG to choose file with prompt "請選擇 iTunes 12.6 dmg 安裝文件:" of type {"dmg"} do shell script "hdiutil mount " & quoted form of POSIX path of theDMG do shell script "pkgutil --expand /Volumes/iTunes/Install\\ iTunes.pkg ~/tmp" do shell script "sed -i '' 's/18A1/14F2511/g' ~/tmp/Distribution" do shell script "sed -i '' 's/gt/lt/g' ~/tmp/Distribution" do shell script "pkgutil --flatten ~/tmp ~/Desktop/iTunes.pkg" do shell script "hdiutil unmount /Volumes/iTunes/" do shell script "rm -rf ~/tmp" end if if answer is equal to "No" then display dialog "iTunes 未刪除" buttons {"OK"} return end if set question to display dialog "肯定是否安裝 iTtunes 12.6 ?" buttons {"Yes", "No"} default button 1 set answer to button returned of question if answer is equal to "Yes" then do shell script "open ~/Desktop/iTunes.pkg" return end if if answer is equal to "No" then display dialog "已修改的 iTunes.pkg 文件保存在桌面" buttons {"OK"} return end if