Removing Office 2011

g1za
New Contributor III

Hi,

How would i completely remove Office 2011 on a network via Casper/JSS?

I've found the 12 step guide to removing the software from Microsoft: http://support.microsoft.com/kb/2398768/en-us

Would i do this while running composer to create a package and send out?

40 REPLIES 40

jarednichols
Honored Contributor

Create a script that kills all the locations the article refers to and push it out with a policy targeted to systems with Office 2011

g1za
New Contributor III

This has been resolved with a series of policies to remove all the settings etc.

mahughe
Contributor

was Office 2011 installed via casper? if so, index the pkg ..create a policy to remove from those clients you wish to remove it from.

itupshot
Contributor II

I'm using the following script to remove Office 2011 in preparation to install Office 2016. However, I just realized I'm not sure how to tell it to remove ~/Library/Application Support/Microsoft/Office

This folder contains Script Menu scripts, templates, etc., for O-2011 that won't be needed anymore. I need to weed this folder out of every user's home folder. I'm not sure if I should use the path I put above, or if there's another way of phrasing it since it has to work on any user's home folder.

#!/bin/sh
    osascript -e 'tell application "Microsoft Database Daemon" to quit'
    osascript -e 'tell application "Microsoft AU Daemon" to quit'
    osascript -e 'tell application "Office365Service" to quit'
    rm -R '/Applications/Microsoft Communicator.app/'
    rm -R '/Applications/Microsoft Messenger.app/'
    rm -R '/Applications/Microsoft Office 2011/'
    rm -R '/Applications/Remote Desktop Connection.app/'
    rm -R '/Library/Application Support/Microsoft/MAU2.0'
    rm -R '/Library/Application Support/Microsoft/MERP2.0'
    rm -R /Library/Automator/*Excel*
    rm -R /Library/Automator/*Office*
    rm -R /Library/Automator/*Outlook*
    rm -R /Library/Automator/*PowerPoint*
    rm -R /Library/Automator/*Word*
    rm -R /Library/Automator/*Workbook*
    rm -R '/Library/Automator/Get Parent Presentations of Slides.action'
    rm -R '/Library/Automator/Set Document Settings.action'
    rm -R /Library/Fonts/Microsoft/
    rm -R /Library/Internet Plug-Ins/SharePoint*
    rm -R /Library/LaunchDaemons/com.microsoft.*
    rm -R '/Library/Preferences/com.microsoft.office.licensing.plist'
    rm -R /Library/PrivilegedHelperTools/com.microsoft.*
    OFFICERECEIPTS=$(pkgutil --pkgs=com.microsoft.office.*)
    for ARECEIPT in $OFFICERECEIPTS
    do
        pkgutil --forget $ARECEIPT
    done
exit 0

mm2270
Legendary Contributor III

@itupshot

for user in $(ls /Users/); do
    echo "Checking user: $user"
    if [ -d "/Users/$user/Library/Application Support/Microsoft/Office" ]; then
        echo "Found folder for user ${user}. Removing..."
        rm -Rfd "/Users/$user/Library/Application Support/Microsoft/Office"
    fi
done

itupshot
Contributor II

@mm2270 Thanks for the tip! I'll try that. I need to run a test of my script on a couple of machines today.

danny_hanes
Contributor

@itupshot Have you had a chance to update / test your script? I am looking for an uninstaller for when we roll out 2016 later this month.

mavereb
New Contributor

Any luck with this it is the last linc in my Office 2016 Deploy log..Got rm -rf "/Applications/Microsoft Office 2011" to work in terminal,but not in script
M

swapple
Contributor III

Is it safe to run this after 2016 has been installed? so far I am seeing O16 makes new files, assuming it makes new files of everything and does not use any left behind by O11.

dpalmer_autoeve
New Contributor III

I am going to try this script on a test system and see how it works, I am going to run pre and post O16 install. Has anyone had any issues with this?

talkingmoose
Moderator
Moderator

Office 2011 and Office 2016 share no common files except for the Microsoft AutoUpdate tool found in /Library/Application Support/Microsoft. If you run your script to remove Outlook 2011 then be sure use an octothorp (I LOVE that word!) to comment this line and keep it from running:

# rm -R '/Library/Application Support/Microsoft/MAU2.0'

Two other parts of the script remove pieces in the /Library folder via wildcard. Either comment these lines too or specify the exact file to remove for Office 2011:

# rm -R /Library/LaunchDaemons/com.microsoft.*

or

rm -R /Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist

As well as:

# rm -R /Library/PrivilegedHelperTools/com.microsoft.*

or

rm -R /Library/PrivilegedHelperTools/com.microsoft.office.licensing.helper

tcandela
Valued Contributor II

i want the office 2011 to remove the autoupdate. I am managing updates of 2016 via Casper policy when an update to office 2016 is available.

rm -R '/Library/Application Support/Microsoft/MAU2.0'

my office 2016 install policy uses a choices.xml that leaves out OUTLOOK and AutoUpdate

so if i don't remove MAU2.0, then my Office2016 install uses it for AutoUpdate

anpender
New Contributor

Will Office 2016 pick up any existing prefs that users might have set - i.e. perhaps we should leave them in place?

bpavlov
Honored Contributor

@anpender depends on the app and what prefs, but i don't think there's much being shared between the two apps in terms of preferences. i think Auto Update still uses some similar prefs. a lot of things were also moved to an sqlite database. i'm not sure if the office apps will attempt to read from prefs in previous version of Office apps on first run or during install. might be worth testing. but i work off the assumption that it does not transfer those prefs over (except Outlook which does try to import accounts/settings if you previously had it setup).

Goose02
New Contributor II

Anyone have a fully baked version of this script? I would love to be able to push this out to get rid of office 2011 on our macs what already have office 2016 installed, were new to the macs being managed this way, thus no old packages to reference.

danny_hanes
Contributor

@Goose02 Give the macadmins.software site a shot.

stevevalle
Contributor III

Here is the script I use to uninstall Office 2011. It also removes dock icons (we use dockutil)

#!/bin/sh

    osascript -e 'tell application "Microsoft Database Daemon" to quit'
    osascript -e 'tell application "Microsoft AU Daemon" to quit'
    osascript -e 'tell application "Office365Service" to quit'


    /bin/test -e '/Applications/Microsoft Office 2011/Microsoft Word.app/' && /usr/local/bin/dockutil --remove 'Microsoft Word' --allhomes --no-restart
    /bin/test -e '/Applications/Microsoft Office 2011/Microsoft Outlook.app/' && /usr/local/bin/dockutil --remove 'Microsoft Outlook' --allhomes --no-restart
    /bin/test -e '/Applications/Microsoft Office 2011/Microsoft PowerPoint.app/' && /usr/local/bin/dockutil --remove 'Microsoft PowerPoint' --allhomes --no-restart
    /bin/test -e '/Applications/Microsoft Office 2011/Microsoft Excel.app/' && /usr/local/bin/dockutil --remove 'Microsoft Excel' --allhomes --no-restart
    /bin/test -e '/Applications/Microsoft Communicator.app/' && /usr/local/bin/dockutil --remove 'Microsoft Communicator' --allhomes --no-restart
    /bin/test -e '/Applications/Microsoft Messenger.app/' && /usr/local/bin/dockutil --remove 'Microsoft Messenger' --allhomes --no-restart
    /bin/test -e '/Applications/Microsoft Office 2011/Microsoft Document Connection.app/' && /usr/local/bin/dockutil --remove 'Microsoft Document Connection' --allhomes --no-restart
    /bin/test -e '/Applications/Remote Desktop Connection.app/' && /usr/local/bin/dockutil --remove 'Remote Desktop Connection' --allhomes --no-restart

    killall Dock


    /bin/test -e '/Applications/Microsoft Communicator.app/' && rm -R '/Applications/Microsoft Communicator.app/'
    /bin/test -e '/Applications/Microsoft Lync.app/' && rm -R '/Applications/Microsoft Lync.app/'
    /bin/test -e '/Applications/Microsoft Messenger.app/' && rm -R '/Applications/Microsoft Messenger.app/'
    /bin/test -e '/Applications/Remote Desktop Connection.app/' && rm -R '/Applications/Remote Desktop Connection.app/'

    rm -R '/Applications/Microsoft Office 2011/'

    rm -R '/Library/Application Support/Microsoft/'
    rm -R /Library/Automator/*Excel*
    rm -R /Library/Automator/*Office*
    rm -R /Library/Automator/*Outlook*
    rm -R /Library/Automator/*PowerPoint*
    rm -R /Library/Automator/*Word*
    rm -R /Library/Automator/*Workbook*
    rm -R '/Library/Automator/Get Parent Presentations of Slides.action'
    rm -R '/Library/Automator/Set Document Settings.action'

    rm -R /Library/Internet Plug-Ins/SharePoint*
    rm -R /Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist
    rm -R /Library/Preferences/com.microsoft.office.licensing.plist
    rm -R /Library/PrivilegedHelperTools/com.microsoft.office.licensing.helper

    rm -R /Library/Fonts/Microsoft/

    mv '/Library/Fonts Disabled/Arial Bold Italic.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Arial Bold.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Arial Italic.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Arial.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Brush Script.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Times New Roman Bold Italic.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Times New Roman Bold.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Times New Roman Italic.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Times New Roman.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Verdana Bold Italic.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Verdana Bold.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Verdana Italic.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Verdana.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Wingdings 2.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Wingdings 3.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Wingdings.ttf' /Library/Fonts

    exit 0

Hope that helps!

talkingmoose
Moderator
Moderator

@pbowden with Microsoft has written a removal script for Office 2011. You'll find it here:

https://github.com/pbowden-msft/Remove2011/blob/master/Remove2011

I believe I made this work with a Jamf policy by adding this as a script to Jamf and under the Options tab setting the label for Parameter 4 to "Additional Arguments". Then I added the script to a policy and entered --Force in the Additional Arguments field.

Test this and if it doesn't work, you may also need to change $1 to $4 on line 435 of the script.

acaveny
New Contributor III

@talkingmoose

Did you have any instances where 2011 and 2016 were installed side by side? If so - how did you differentiate?

talkingmoose
Moderator
Moderator

@acaveny, installing 2011 and 2016 side-by-side is fully supported by Microsoft. They share no common files or preferences other than Microsoft AutoUpdate.

The paths to the applications is the easiest way to differentiate the two installs. Office 2011 installs its apps together in '/Applications/Microsoft Office 2011' and Office 2016 installs its apps loose in the /Applications folder.

tcandela
Valued Contributor II

@talkingmoose - this is what i get when i run the policy to uninstall office 2011 using the script. I setup the additional arguments and the --Force

Script exit code: 1
Script result: [0;34m=== Microsoft Office 2011 for Mac Removal Tool 1.3 ===[0m
Usage: SNHS-Remove Office 2011.sh [--Force] [--Help] [--SaveLicense]
Use --Force to bypass warnings and forcibly remove Office 2011 applications and data
Error running script: return code was 1.

tcandela
Valued Contributor II

gonna change line 435 to key="$4". i'll let you know what happens

tcandela
Valued Contributor II

I get the same error result when changing line 435 to $4

here is the error logged in the casper policy

Running script Uninstall Office 2011.sh...
Script exit code: 1
Script result: [0;34m=== Microsoft Office 2011 for Mac Removal Tool 1.3 ===[0m
Usage: Uninstall Office 2011.sh [--Force] [--Help] [--SaveLicense]
Use --Force to bypass warnings and forcibly remove Office 2011 applications and data
Error running script: return code was 1.

---- below is the part of the script code

Evaluate command-line arguments

if [[ $# = 0 ]]; then LogMessage "No command-line arguments passed, going into interactive mode" MainLoop else LogMessage "Command-line arguments passed, attempting to parse" while [[ $# > 0 ]] do key="$4" <-------------------------------------------------- this is line 435 LogMessage "Argument: $key" case $key in --Help|-h|--help) ShowUsage exit 0 shift # past argument ;; --Force|-f|--force) LogMessage "Force mode set to TRUE" FORCE_PERM=true shift # past argument ;; --SaveLicense|-s|--savelicense) LogMessage "SaveLicense set to TRUE" SAVE_LICENSE=true shift # past argument ;; *) ShowUsage exit 1 ;; esac shift # past argument or value done MainLoop fi

talkingmoose
Moderator
Moderator

@tcandela, I've made this work for another customer. I'll need to go check my notes and test a little. I'll let you know what I find.

talkingmoose
Moderator
Moderator

@tcandela, following are my changes to @pbowden's Remove 2011 script to make it work with Jamf:

Line 21 - change:
touch $LOG_FILE to
touch "$LOG_FILE"

Line 437 - change:
case $key in to
case "$key" in

Line 454 - change:
ShowUsage to
echo "Ignoring unrecognized argument: $key"

Line 455 - change:
exit 1 to
# exit 1

When adding the script contents to Jamf, be sure to set the "Parameter 4" label under the Options tab to something like "Additional Parameter 1".

When adding the script to your removal policy, be sure to set the "Additional Parameter 1" field to "--Force".

Removing user preferences [ Optional ]

Note the script supports removing the current user's preference files. That means, if running from Jamf, it'll attempt to remove root's preferences (those probably don't exist) and will leave preferences in user home folders alone. If you want to remove preferences in all user home folders, open the script in a plain text editor such as BBEdit or TextWrangler and use Find/Replace to change all references of:

$HOME to
/Users/*

Troubleshooting

I found during my testing if I call the policy via Terminal, the script log gets placed into the top level of the current user's home folder. It can be useful for troubleshooting should you need it:

sudo jamf policy -id 38 <-- Replace "38" with the ID number of your own removal policy found in the URL

tcandela
Valued Contributor II

@talkingmoose talk do I need to still keep line 435 to key="$4" ?

talkingmoose
Moderator
Moderator

@tcandela, only the changes I mentioned above. Leave line 435 as-is.

tcandela
Valued Contributor II

@talkingmoose hey, I made those 4 changes to the script

kept line 435 to key="$1"

"Parameter 4" label under the Options tab to something like Additional Parameter (no quotes)
Additional Parameter 1 field to --Force (no quotes)

left all the $HOME alone for now in the script

testing soon

tcandela
Valued Contributor II

@talkingmoose hey, 'moose' it worked. results of the script are below.

what i'm trying to do now is 'clean the dock' of any Office 2011 dock items that the user might have added to their dock. In the Script i see the function that does this removal, but the code in this function is based on using DOCKUTIL

these computers do not have DOCKUTIL installed, so i'm trying to adjust the ELSE clause to specifically go into the dock and remove any office 2011 items. The CleanDock function is below.

i understand the dock.plist for each user is in Dock preferences are in ~/Library/Preferences/com.apple.dock.plist
would just a refresh of the users Dock eliminate any Office 2011 dock items? I might put this Office 2011 uninstall in Self Service for the person to run it.

function CleanDock { LogMessage "In function 'CleanDock'" FormattedConsoleMessage "%-55s" "Cleaning icons in dock" if [ -e "$WORKING_FOLDER/dockutil" ]; then LogMessage "Found DockUtil tool" sudo "$WORKING_FOLDER"/dockutil --remove "file:///Applications/Microsoft%20Office%202011/Microsoft%20Document%20Connection.app/" --no-restart sudo "$WORKING_FOLDER"/dockutil --remove "file:///Applications/Microsoft%20Office%202011/Microsoft%20Word.app/" --no-restart sudo "$WORKING_FOLDER"/dockutil --remove "file:///Applications/Microsoft%20Office%202011/Microsoft%20Excel.app/" --no-restart sudo "$WORKING_FOLDER"/dockutil --remove "file:///Applications/Microsoft%20Office%202011/Microsoft%20PowerPoint.app/" --no-restart sudo "$WORKING_FOLDER"/dockutil --remove "file:///Applications/Microsoft%20Office%202011/Microsoft%20Outlook.app/" LogMessage "Completed dock clean-up" ConsoleMessage "${TEXT_GREEN}Success${TEXT_NORMAL}" else ConsoleMessage "${TEXT_YELLOW}Not detected${TEXT_NORMAL}" fi }
Running script Uninstall Office 2011.sh... Script exit code: 0 Script result: [0;34m=== Microsoft Office 2011 for Mac Removal Tool 1.3 ===[0m Removing Office 2011 Applications [0;32mSuccess[0m Removing Launch Daemon: Licensing Helper [0;32mSuccess[0m Removing Helper Tools: Licensing Helper [0;32mSuccess[0m Removing Office Fonts [0;32mSuccess[0m Removing Product License [0;32mSuccess[0m Removing Error Reporting [0;32mSuccess[0m Removing Application Support [0;32mSuccess[0m Removing Browser Font Cache [0;33mNot detected[0m Removing Setup Assistant Cache [0;33mNot detected[0m Removing Office Cache [0;32mSuccess[0m Removing Outlook Identity Cache [0;33mNot detected[0m Removing Outlook Cache [0;33mNot detected[0m Removing Preferences [0;32mSuccess[0m Preserving Outlook Identities and Databases [0;32mSuccess[0m Preserving Outlook Saved Attachments [0;33mNot detected[0m Preserving Outlook Sound Sets [0;33mNot detected[0m Removing Package Receipts [0;32mSuccess[0m Cleaning icons in dock [0;33mNot detected[0m Restarting Preferences Daemon [0;32mSuccess[0m All events and errors were logged to /var/folders/4r/9z7hv6t9571_9cwj2dpt57z40000gn/T/Uninstall Office 2011.sh.log

Vernaf
New Contributor II

This script (Remove2011) asks a few questions at the beginning. How to I set it up so that the answers are predetermined so there's no user interaction?

talkingmoose
Moderator
Moderator

@tcandela, I suggest simply using dockutil. It's good. It's simple and it works well. It can remove a dock icon from all user home folders as well as the User Template. Just deploy it along with the script.

tcandela
Valued Contributor II

@talkingmoose I just ran the script again and noticed it does not remove the following folder

/library/application support/microsoft/mau2.0 /library/application support/microsoft

so i had to do it manually

I want auto updates removed because i have office 2016 updates run through casper policies

checking the script to see where i can add this

should i add this to the main loop in the following section

Remove Office 2011 application support --

RemoveComponent "/Library/Application Support/Microsoft/MAU2.0" "Auto Update"

talkingmoose
Moderator
Moderator

@tcandela, you'll have to add that to the script yourself.

The script was written to remove Office 2011 but it and Office 2016 share the Microsoft AutoUpdate (MAU) tool. Therefore, the script doesn't delete what may have been installed by Office 2016.

Rather than remove MAU using this script, you may want to create another smaller script that does just this and run it separately on machines where you find it's installed.

tcandela
Valued Contributor II

@talkingmoose I just added

RemoveComponent "/Library/Application Support/Microsoft/MAU2.0" "Auto Update"
RemoveComponent "/Library/Application Support/Microsoft" "Microsoft App Support Folder"

should do it, testing soon

so now that section looks like this

# Remove Office 2011 application support RemoveComponent "/Library/Application Support/Microsoft/MERP2.0" "Error Reporting" RemoveComponent "/Library/Application Support/Microsoft/MAU2.0" "Auto Update" RemoveComponent "$HOME/Library/Application Support/Microsoft/Office" "Application Support" RemoveComponent "/Library/Application Support/Microsoft" "Microsoft App Support Folder"

tcandela
Valued Contributor II

@talkingmoose hey, it works, I could have probable just did this single line, removing MERP2.0 & MAU2.0

RemoveComponent "/Library/Application Support/Microsoft" "Microsoft App Support Folder"

what is this following line? --> RemoveComponent "$HOME/Library/Application Support/Microsoft/Office" "Application Support"

I am confused about $HOME --> where is this referring to ?

talkingmoose
Moderator
Moderator

@tcandela, most any word you see in a shell script like this that begins with $ means it's a variable — a placeholder for another piece of information.

In this case, if you run echo $HOME in Terminal, you'll see it returns the path to your own home folder. If my username is mmoose then $HOME means /Users/mmoose.

And if you see something like $HOME/Library/Preferences/com.mircrosoft.Word.plist then that expands to /Users/mmoose/Library/Preferences/com.mircrosoft.Word.plist.

Keep in mind that $HOME is relative to whoever is logged in and running the script.

sam_g
Contributor
Contributor

@talkingmoose - dumb question but I figure you can answer it quickly. When you said above

@tcandela, I suggest simply using dockutil. It's good. It's simple and it works well. It can remove a dock icon from all user home folders as well as the User Template. Just deploy it along with the script.

Do you mean add the dockutil script to the policy along with the modified Remove2011 script? When I do that, the policy returns with an error because dockutil tries to run and doesn't have any arguments supplied. How exactly do you suggest "deploying it along with the script?"

Thanks!

talkingmoose
Moderator
Moderator

@sag969, Dockutil is meant to be deployed to systems and reside there for other scripts to call. Wherever you decide to put it, you'll need to update the path in @pbowden's script to point to Dockutil.

Looks like his script declares a variable near the top:

WORKING_FOLDER=$(dirname "$0")

This appears to only be for describing where Dockutil lives on the Mac. You should be able to set this to something like:

WORKING_FOLDER="/private/tmp"

Then, package the Dockutil tool using Composer and deploy it to the /private/tmp folder. I know some administrators like to keep Dockutil on all their Macs for future use. You want want to instead deploy it permanently to a place like "/Library/Company Name/Scripts" and call it from there.

I haven't tested this, but from what I see in the script, it should work this way.

pbowden
Contributor III

@talkingmoose @sag969 Just a word of caution that you should use the version of Dockutil that I supply with the Remove2011 script at https://github.com/pbowden-msft/Remove2011 as it contains a couple of tweaks of Kyle's base version, that has better handling for icon removal of Office apps.