梅1820 发表于 2016-5-16 07:23:37

Mac OS X: 实用脚本程序(bash scripts)系列-10

Mac OS X: 实用脚本程序(bash scripts)系列-10

--Preferences的几个例子
  
  举几个通过变更Plist文件改变系统行为的例子:
  
1.1 电脑管理员可以设置需要Admin来控制Airport的功能,在Mac OS X 10.5 Leopard中首次提供。在GUI环境中很容易做到,见下图:
  

  
  对应的shell:
  plistbuddy -c "Add $currentSet:Network:Interface:en1:AirPort:RequireAdmin bool yes" /Library/Preferences/SystemConfiguration/preferences.plist
  
1.2 Snow Leopard中的设置:
  

  对应的shell:
  plistbuddy -c "Add $currentSet:Network:Interface:en1:AirPort:RequireAdminPowerToggle bool yes" /Library/Preferences/SystemConfiguration/preferences.plist
2. 禁止用户打开Finder的Preferences的shell:

  defaults write com.apple.finder ProhibitFinderPreferences -bool YES
  
3. 禁止Finder在Sidebar中显示Shared的机器列表:
  plistbuddy -c "set :networkbrowser:CustomListProperties:com.apple.NetworkBrowser.backToMyMacEnabled no"
  plistbuddy -c "set :networkbrowser:CustomListProperties:com.apple.NetworkBrowser.bonjourEnabledno"
  plistbuddy -c "set :networkbrowser:CustomListProperties:com.apple.NetworkBrowser.connectedEnabledno"
  
4. 禁止自动更新

  4. 1 禁止Mac OS X系统自动更新:
  softwareupdate --schedule off
  
  4.2 禁止MS Office 2004自动更新:
  defaults write com.microsoft.autoupdate HowToCheck -string "Manual"
  
  4.3 禁止MS Office 2008自动更新:
  defaults write com.microsoft.autoupdate2 HowToCheck -string "Manual"
  
  4.4 禁止Adobe CS3自动更新
  sed -i "" 's:<AutoCheck>1</AutoCheck>:<AutoCheck>0</AutoCheck>:' /
/Users/$USER/Library/Application/ Support/Adobe/Updater5/AdobeUpdaterPrefs.dat
  
  4.5 禁止Adobe CS4自动更新
  sed -i "" 's:<AutoCheck>1</AutoCheck>:<AutoCheck>0</AutoCheck>:' /
/Users/$USER/Library/Application/ Support/Adobe/Updater6/AdobeUpdaterPrefs.dat


5.迫使Safari 4在tab中打开新网页
  defaults write com.apple.Safari TargetedClicksCreateTabs -bool true
  
  
页: [1]
查看完整版本: Mac OS X: 实用脚本程序(bash scripts)系列-10