Skip to content

Instantly share code, notes, and snippets.

@rtrouton
Created April 17, 2017 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtrouton/36ffb38993823f86d93bd69da410d062 to your computer and use it in GitHub Desktop.
Save rtrouton/36ffb38993823f86d93bd69da410d062 to your computer and use it in GitHub Desktop.
Set the Open and Save options in Office 2016 apps to default to "On My Mac" instead of "Online Locations" for Office 2016 15.32.x and earlier.
#!/bin/bash
# Set the Open and Save options in Office 2016 apps to default to
# "On My Mac" instead of "Online Locations" in the default user template
for USER_TEMPLATE in "/System/Library/User Template"/*
do
/usr/bin/defaults write "${USER_TEMPLATE}/Library/Group Containers/UBF8T346G9.Office/"com.microsoft.officeprefs DefaultsToLocalOpenSave -bool true
done
# Set the Open and Save options in Office 2016 apps to default to
# "On My Mac" instead of "Online Locations" in the user folders
# located in /Users, then fixes the permissions on the affected
# file so that the file is owned by the user folder's owner rather
# than being owned by root.
for USER_HOME in /Users/*
do
USER_UID=`basename "${USER_HOME}"`
if [ ! "${USER_UID}" = "Shared" ]; then
if [ ! -d "${USER_HOME}/Library/Group Containers/UBF8T346G9.Office" ]; then
/bin/mkdir -p "${USER_HOME}/Library/Group Containers/UBF8T346G9.Office"
/usr/sbin/chown "${USER_UID}" "${USER_HOME}/Library"
/usr/sbin/chown "${USER_UID}" "${USER_HOME}/Library/Group Containers"
/usr/sbin/chown "${USER_UID}" "${USER_HOME}/Library/Group Containers/UBF8T346G9.Office"
fi
if [ -d "${USER_HOME}/Library/Group Containers/UBF8T346G9.Office" ]; then
/usr/bin/defaults write "${USER_HOME}/Library/Group Containers/UBF8T346G9.Office/"com.microsoft.officeprefs DefaultsToLocalOpenSave -bool true
/usr/sbin/chown "${USER_UID}" "${USER_HOME}/Library/Group Containers/UBF8T346G9.Office/"com.microsoft.officeprefs.plist
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment