Paul Calnan
Published August 11, 2012

I'm not a fan of Microsoft Outlook. Unfortunately, I'm often required to use it. Most of the time, a combination of Apple's and iCal is good enough to get the job done. However, there are occasions that you need to use Outlook. In particular, Outlook is the only way to set a server-side rule on an Exchange server.

So, every once in a while I need to fire up Outlook to create a new rule. Here's the part that really gets on my nerves: Every time you launch Outlook on OS X, it launches Microsoft Office Reminders which shows a popup window with reminders for all of your appointments. Additionally, it launches Microsoft Database Daemon and adds it to your Login Items.

Rather than having to quit out of Microsoft Office Reminders and go into System Preferences > Users & Groups > Login Items every time I run Outlook, I wrote a little script to do it for me.

Since I usually have a Terminal window open, I simply run kill-mso-remnants after I quit Outlook and we're back to where we started.

The script:

#!/usr/bin/env bash

# Kill the two processes.
for PROC in "Microsoft Database Daemon" "Microsoft Office Reminders"; do
    echo "Killing $PROC"
    killall "$PROC"

# This plist file contains your Login Items.

# PlistBuddy lets you edit plist files from the command line.

# The app that gets added to your Login Items.
APP_NAME="/Applications/Microsoft Office 2011/Office/Microsoft Database"

# This loop searches the plist file for the offending application and, if it's
# found, removes it.
while :
    # Print the application path for this item in the list and capture the
    # output.
    OUTPUT=$($PLIST_BUDDY $PLIST_FILE -c "Print :AutoLaunchedApplicationDictionary:$INDEX:Path" 2>&1)

    # If the output is the name of the offending application...
    if [ "$OUTPUT" = "$APP_NAME" ]; then
        # Delete the containing element from the plist file.
        $PLIST_BUDDY $PLIST_FILE -c "Delete :AutoLaunchedApplicationDictionary:$INDEX"
        echo "Entry for $APP_NAME deleted from $PLIST_FILE"

    # If the output matches "Does Not Exist", we have finished searching
    # without finding a match.
    elif [[ "$OUTPUT" =~ "Does Not Exist" ]]; then
        echo "Could not find Plist entry for $APP_NAME"

    INDEX=$((INDEX + 1))