This article explains how to deploy Universal Print Driver quick codes to managed macOS devices using Mosyle.
The configuration is stored in the following macOS preference file:
/Library/Preferences/universalPrintDriver.plist
/Library/Preferences/universalPrintDriver.plistis a file path, not a folder.
Configuration example
The following plist configures two quick codes:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UPD_QUICKCODES</key>
<string>5qvp,en7b</string>
</dict>
</plist>
Multiple quick codes must be entered as a comma-separated string.
For example:
5qvp,en7b
Do not include spaces unless the quick code itself contains a space.
Recommended deployment method
The recommended approach is to use a Mosyle Custom Command that updates only the UPD_QUICKCODES preference.
This preserves any other settings that may already exist in the universalPrintDriver.plist file.
Use the following script:
#!/bin/bash
PLIST_PATH="/Library/Preferences/universalPrintDriver.plist"
QUICK_CODES="5qvp,en7b"
/usr/bin/defaults write /Library/Preferences/universalPrintDriver \
UPD_QUICKCODES -string "$QUICK_CODES"
if [[ ! -f "$PLIST_PATH" ]]; then
echo "ERROR: The preference file was not created."
exit 1
fi
/usr/sbin/chown root:wheel "$PLIST_PATH"
/bin/chmod 644 "$PLIST_PATH"
/usr/bin/killall cfprefsd 2>/dev/null || true
echo "Universal Print Driver quick codes configured successfully."
echo "Configured value:"
/usr/bin/defaults read /Library/Preferences/universalPrintDriver \
UPD_QUICKCODES
exit 0
Before deployment, replace the value below with the quick codes required for the organisation:
QUICK_CODES="5qvp,en7b"
Configure the command in Mosyle
- Sign in to the Mosyle administrator console.
- Open the macOS management area.
- Create a new Custom Command or script-based profile.
Enter a name such as:
Configure Universal Print Driver Quick Codes
- Paste the deployment script into the command field.
- Assign the command to the required Macs, users or device groups.
- Configure the command to run as the system or root account.
- Save and deploy the command.
Mosyle normally executes device management scripts with the permissions required to write to /Library/Preferences.
Deployment frequency
Choose the deployment frequency based on the required behaviour.
Run once
Use a one-time deployment when the quick codes only need to be configured during installation or initial device setup.
Recurring deployment
Use a recurring deployment when the configured value must be regularly enforced.
For example, a daily command can restore the required setting if the plist is manually changed or removed.
Verify the configuration
Run the following command on the Mac:
/usr/bin/defaults read /Library/Preferences/universalPrintDriver \
UPD_QUICKCODES
The expected result is:
5qvp,en7b
You can also inspect the complete preference file:
/usr/bin/plutil -p /Library/Preferences/universalPrintDriver.plist
Example output:
{
"UPD_QUICKCODES" => "5qvp,en7b"
}
To validate that the file is a correctly formatted plist, run:
/usr/bin/plutil -lint /Library/Preferences/universalPrintDriver.plist
The expected result is:
/Library/Preferences/universalPrintDriver.plist: OK
Deploying the complete plist
The following script can be used when the entire universalPrintDriver.plist file should be created or replaced.
This method overwrites any existing settings in the plist. Use the recommended
defaults writemethod when other settings must be preserved.
#!/bin/bash
PLIST_PATH="/Library/Preferences/universalPrintDriver.plist"
TEMP_PLIST="$(/usr/bin/mktemp /tmp/universalPrintDriver.XXXXXX.plist)"
cat > "$TEMP_PLIST" <<'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UPD_QUICKCODES</key>
<string>5qvp,en7b</string>
</dict>
</plist>
PLIST
if ! /usr/bin/plutil -lint "$TEMP_PLIST" >/dev/null 2>&1; then
echo "ERROR: The generated plist is invalid."
/bin/rm -f "$TEMP_PLIST"
exit 1
fi
/usr/bin/install -o root -g wheel -m 644 \
"$TEMP_PLIST" "$PLIST_PATH"
/bin/rm -f "$TEMP_PLIST"
/usr/bin/killall cfprefsd 2>/dev/null || true
echo "The preference file was installed successfully."
/usr/bin/plutil -p "$PLIST_PATH"
exit 0
Troubleshooting
The plist is not created
Confirm that the Mosyle command is running as the system or root account.
Standard macOS users cannot normally write files to:
/Library/Preferences
The setting does not appear immediately
macOS caches preference values through the cfprefsd process.
The deployment script refreshes this cache using:
/usr/bin/killall cfprefsd
Restart the Universal Print Driver application after deploying the setting. In some cases, signing out or restarting the Mac may also be required.
Existing settings have disappeared
This can happen when the complete-plist deployment method is used.
Use the recommended defaults write script to update only the UPD_QUICKCODES key without replacing the rest of the file.
The quick codes are not recognised
Confirm that:
- Each quick code is valid.
- Multiple codes are separated using commas.
- There are no unwanted spaces.
- The value is stored as a string rather than an array.
- The Universal Print Driver application has been restarted since the setting was deployed.
Removing the setting
To remove the UPD_QUICKCODES preference without deleting the complete plist, deploy the following command:
#!/bin/bash
/usr/bin/defaults delete /Library/Preferences/universalPrintDriver \
UPD_QUICKCODES 2>/dev/null || true
/usr/bin/killall cfprefsd 2>/dev/null || true
echo "The Universal Print Driver quick-code setting was removed."
exit 0