Apple’s Installer command line tool can install both Microsoft Office for Mac 2008 and 2011 because they are delivered by Microsoft in Apple’s Package format. Command line installation is ideal for distribution of software to multiple computers because it can be done across the network from a central location. Shell scripts can call the Installer as part of a larger set of scripted commands making this one of the most versatile methods of delivering software.
Basic command line installation
The basic command contains two parts. The first part is the path to the package to be installed and the second part is the path to the target volume. Assuming the Office Installer.mpkg file has been copied to the /private/tmp folder of computer and that the system is also the target volume, the basic command is:
installer -package "/private/tmp/Office Installer.mpkg" -target /
Because Office for Mac is installed into the /Applications folder and some of its components are installed in the /Library folder, the Office Installer.mpkg file must be installed by an administrator. He can invoke root privileges using the sudo command if needed.
By default, all components of Microsoft Office for Mac are installed whether double-clicking the Office Installer.mpkg file or installing it from the command line. To selectively install components during a command line installation requires a choices file. This file is deployed with the installer and called as part of the command line instructions.
To view a list of choices available in the Office Installer.mpkg file, the command is (one line):
installer -package "/private/tmp/Office Installer.mpkg" -showChoicesXML | grep -A 1 choiceIdentifier
Each choiceIdentifier matches one of the choices in the GUI installer.
Creating the Choices file is as simple as including the desired choiceIdentifiers in an array in an XML file. However, knowing the desired choiceIdentifiers can be tricky. To start the file, use any text editor such as TextEdit to create a new file called mychoices.xml.
Including a choiceIdentifier in the mychoices.xml file is the equivalent of selecting or deselecting the choice in the GUI. Remember, everything is selected by default to be installed. To deselect an item then add its choiceIdentifier to the Choices file. For example, to install everything except Fonts and Dock Icons, add the fonts and the dock choiceIdentifiers to the mychoices.xml file:
<array> <string>fonts</string> <string>dock</string> </array
To install everything except the Proofing Tools languages but leave the English Proofing Tools language, the mychoices.xml file would contain:
<array> <string>proofing-tools</string> <string>english</string> </array
As the mychoices.xml file is applied, everything will be installed except the Proofing Tools, which is deselected. However, with all Proofing Tools being deselected, adding the English Proofing Tool into the mychoices.xml file now reselects it. Likewise, if the Proofing Tools were deselected by default then this same file would select all Proofing Tools and then deselect the English Proofing Tool.
Verifying the Choices file
To verify the correct choices will be installed, use this command (one line):
installer -package "/private/tmp/Office Installer.mpkg" -showChoicesAfterApplyingChangesXML /private/tmp/mychoices.xml
Applying the Choices file
Copying the Office Installer.mpkg file and the mychoices.xml file to the /tmp directory of the remote computer where the software will be installed ensures that they will be automatically deleted when that computer is restarted. Files can be copied using Apple Remote Desktop, the command line SCP tool or using any administrative tools available.
Once both files are located in the /tmp directory then run this command (one line):
installer -package "/private/tmp/Office Installer.mpkg" -target / -applyChoiceChangesXML /private/tmp/mychoices.xml
To learn more about the command line Installer, open the Terminal.app application found in /Applications/Utilities and enter:
To learn more about making a Choices file, read Creating an Installer Choice Changes XML file for Leopard by Patrick Fergus on AFP548.com.