Issue uninstalling Office 2016

Not sure if anyone has tried to uninstall Office 2016 using PADT, but the Deploy-Application.exe Uninstall does not work.
For my uninstall i have
Execute-Process -Path “cscript.exe” -Parameters “”$dirSupportFiles\OffScrub_O16msi.vbs" ClientAll /S /Q /NoCancel" -WindowStyle Hidden -IgnoreExitCodes ‘1,2,3’
When i run this it actually launches the Office setup box, with options to Add/Remove features, Remove, Repair or add a key.
Then I tried this
Execute-Process -Path “$dirFiles\Setup.exe” -Parameters “/CONFIGURE uninstall.xml”
and i get the same thing.

If i manually run the OffScrub 2016 file it works fine, just not as an Uninstall option.

Can’t seem to figure out why it keeps doing this.

I am using the MSI not the O365 CTR (Don’t think it should matter)

It seems running the “Uninstall” looks to run the “install” portion.

So by using Deploy-Application.exe -Uninstall, for some reason when you click on it, it runs the Installation portion

[Initialization] :: Deployment type is [Uninstallation]. PSAppDeployToolkit 3/24/2016 9:33:15 AM 4428 (0x114C) [Installation] :: Spin up progress dialog in a separate thread with message: [Installing Office Professional 2016. This may take some time. Please wait...]. Show-InstallationProgress 3/24/2016 9:33:15 AM 4428 (0x114C) [Installation] :: [C:\WINDOWS\ccmcache\b9\Files\Setup.exe] is a valid fully qualified path, continue. Execute-Process 3/24/2016 9:33:16 AM 4428 (0x114C) [Installation] :: Working Directory is [C:\WINDOWS\ccmcache\b9\Files]. Execute-Process 3/24/2016 9:33:16 AM 4428 (0x114C) [Installation] :: Executing [C:\WINDOWS\ccmcache\b9\Files\Setup.exe]... Execute-Process 3/24/2016 9:33:17 AM 4428 (0x114C)
Then it waits for me to select an option Not sure why it wants to keep running the Installation portion.

Hi Kevin

Had myself many issues with Office 2016 Silent Install and Uninstall. Currently I have the following:
I run the setup.exe of the downloaded Office Package with the Options: /uninstall ProPlus /config VisInstallOffice2016.xml

While the xml is just there to keep it Silent. Its the Config File I use for install but with the /uninstall Parameter it can be used for Uninstall too!

Hope I Helped a bit…

Hi Raphael,

Where do you put this xml file?
I have also tried this with putting the .xml in the root (where setup is), in the Support folder (where the scrub.vbs files are) and still nothing works.
The biggest issue for me is that no matter what i put for the uninstall, it is the Installation part that always runs. If i comment out the installation portion, then nothing happens.

For sanity sake this is my current script. The install works perfectly, it is the uninstall i struggle with.

.SYNOPSIS
This script performs the installation or uninstallation of an application(s).
.DESCRIPTION
The script is provided as a template to perform an install or uninstall of an application(s).
The script either performs an "Install" deployment type or an "Uninstall" deployment type.
The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
.PARAMETER DeploymentType
The type of deployment to perform. Default is: Install.
.PARAMETER DeployMode
Specifies whether the installation should be run in Interactive, Silent, or NonInteractive mode. Default is: Interactive. Options: Interactive = Shows dialogs, Silent = No dialogs, NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not user interactive.
.PARAMETER AllowRebootPassThru
Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. If 3010 is passed back to SCCM, a reboot prompt will be triggered.
.PARAMETER TerminalServerMode
Changes to "user install mode" and back to "user execute mode" for installing/uninstalling applications for Remote Destkop Session Hosts/Citrix servers.
.PARAMETER DisableLogging
Disables logging to file for the script. Default is: $false.
.EXAMPLE
Deploy-Application.ps1
.EXAMPLE
Deploy-Application.ps1 -DeployMode 'Silent'
.EXAMPLE
Deploy-Application.ps1 -AllowRebootPassThru -AllowDefer
.EXAMPLE
Deploy-Application.ps1 -DeploymentType Uninstall
.NOTES
Toolkit Exit Code Ranges:
60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
.LINK
http://psappdeploytoolkit.com
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory=$false)]
[ValidateSet('Install','Uninstall')]
[string]$DeploymentType = 'Install',
[Parameter(Mandatory=$false)]
[ValidateSet('Interactive','Silent','NonInteractive')]
[string]$DeployMode = 'Interactive',
[Parameter(Mandatory=$false)]
[switch]$AllowRebootPassThru = $false,
[Parameter(Mandatory=$false)]
[switch]$TerminalServerMode = $false,
[Parameter(Mandatory=$false)]
[switch]$DisableLogging = $false,
[switch]$addComponentsOnly = $false, # Specify whether running in Component Only Mode
[switch]$addInfoPath = $false, # Add InfoPath to the install
[switch]$addOneNote = $false, # Add OneNote to the install
[switch]$addOutlook = $false, # Add Outlook to the install
[switch]$addPublisher = $false, # Add Publisher to the install
[switch]$addSharepointWorkspace = $false # Add Sharepoint Workspace to the install
)

Try {
## Set the script execution policy for this process
Try { Set-ExecutionPolicy -ExecutionPolicy 'ByPass' -Scope 'Process' -Force -ErrorAction 'Stop' } Catch {}

##*===============================================
##* VARIABLE DECLARATION
##*===============================================
## Variables: Application
[string]$appVendor = 'Microsoft'
[string]$appName = 'Office'
[string]$appVersion = '2016'
[string]$appArch = 'x86'
[string]$appLang = 'EN'
[string]$appRevision = '01'
[string]$appScriptVersion = '3.6.8'
[string]$appScriptDate = '3/28/2016'
[string]$appScriptAuthor = 'Kevin Johnston'
##*===============================================

##* Do not modify section below
#region DoNotModify

## Variables: Exit Code
[int32]$mainExitCode = 0

## Variables: Script
[string]$deployAppScriptFriendlyName = 'Deploy Application'
[version]$deployAppScriptVersion = [version]'3.6.5'
[string]$deployAppScriptDate = '08/17/2015'
[hashtable]$deployAppScriptParameters = $psBoundParameters

## Variables: Environment
If (Test-Path -LiteralPath 'variable:HostInvocation') { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
[string]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent

## Dot source the required App Deploy Toolkit Functions
Try {
	[string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
	If (-not (Test-Path -LiteralPath $moduleAppDeployToolkitMain -PathType 'Leaf')) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
	If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
}
Catch {
	If ($mainExitCode -eq 0){ [int32]$mainExitCode = 60008 }
	Write-Error -Message &quot;Module [$moduleAppDeployToolkitMain] failed to load: <code>n$($_.Exception.Message)</code>n `n$($_.InvocationInfo.PositionMessage)&quot; -ErrorAction &#039;Continue&#039;
	## Exit the script, returning the exit code to SCCM
	If (Test-Path -LiteralPath &#039;variable:HostInvocation&#039;) { $script:ExitCode = $mainExitCode; Exit } Else { Exit $mainExitCode }
}

#endregion
##* Do not modify section above
##*===============================================
##* END VARIABLE DECLARATION
##*===============================================

#  Set the initial Office folder
[string] $dirOffice = Join-Path -Path &quot;$envProgramFilesX86&quot; -ChildPath &#039;Microsoft Office&#039;

If ($deploymentType -ine &#039;Uninstall&#039;) {
	##*===============================================
	##* PRE-INSTALLATION
	##*===============================================
	[string]$installPhase = &#039;Pre-Installation&#039;
		
		#  Verify that Office 2013 is already installed
		$officeVersion = Get-ItemProperty -LiteralPath &#039;HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{90150000-0011-0000-0000-0000000FF1CE}&#039; -ErrorAction &#039;SilentlyContinue&#039; | Select-Object -ExpandProperty DisplayName
		
		#  If not found, display an error and exit
		If (-not $officeVersion) {
			Show-InstallationPrompt -Message &#039;Unable to add the requested components as Office 2013 is not currently installed&#039; -ButtonRightText &#039;OK&#039; -Icon &#039;Error&#039;
		}
	}
	
	## Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, and verify there is enough disk space to complete the install
	Show-InstallationWelcome -CloseApps &quot;excel,groove,onenote,infopath,onenote,outlook,mspub,powerpnt,winword,winproj,visio,lync&quot;
	
		## Display Pre-Install cleanup status
		Show-InstallationProgress -StatusMessage &#039;Performing Pre-Install cleanup. This may take some time. Please wait...&#039;
		
		# Remove any previous version of Office (if required)
        [string[]]$officeExecutables = &#039;excel.exe&#039;, &#039;groove.exe&#039;, &#039;infopath.exe&#039;, &#039;onenote.exe&#039;, &#039;outlook.exe&#039;, &#039;mspub.exe&#039;, &#039;powerpnt.exe&#039;, &#039;winword.exe&#039;, &#039;winproj.exe&#039;, &#039;visio.exe&#039;, &#039;lync.exe&#039;
		ForEach ($officeExecutable in $officeExecutables) {
			If (Test-Path -LiteralPath (Join-Path -Path $dirOffice -ChildPath &quot;Office14\$officeExecutable&quot;) -PathType &#039;Leaf&#039;) {
				Write-Log -Message &#039;Microsoft Office 2010 was detected. Will be uninstalled.&#039; -Source $deployAppScriptFriendlyName
				Execute-Process -Path &quot;cscript.exe&quot; -Parameters &quot;<code>&amp;quot;$dirSupportFiles\OffScrub10.vbs</code>&quot; ProPlus /S /Q /NoCancel&quot; -WindowStyle Hidden -IgnoreExitCodes &#039;1,2,3&#039;
				Break
			}
		}
		ForEach ($officeExecutable in $officeExecutables) {
			If (Test-Path -LiteralPath (Join-Path -Path $dirOffice -ChildPath &quot;Office15\$officeExecutable&quot;) -PathType &#039;Leaf&#039;) {
				Write-Log -Message &#039;Microsoft Office 2013 was detected. Will be uninstalled.&#039; -Source $deployAppScriptFriendlyName
				Execute-Process -Path &quot;cscript.exe&quot; -Parameters &quot;<code>&amp;quot;$dirSupportFiles\OffScrub13.vbs</code>&quot; All /S /Q /NoCancel&quot; -WindowStyle Hidden -IgnoreExitCodes &#039;1,2,3&#039;
				Break
			}
		}
	}
	
	##*===============================================
	##* INSTALLATION
	##*===============================================
	[string]$installPhase = &#039;Installation&#039;
	
	## Install Office 2016
	If (-not $addComponentsOnly) {
  		Show-InstallationProgress -StatusMessage &#039;Installing Office Professional 2016. This may take some time. Please wait...&#039;
		Execute-Process -Path &quot;$dirFiles\Setup.exe&quot; -WindowStyle Hidden -IgnoreExitCodes &#039;3010&#039;        }
	##*===============================================
	##* POST-INSTALLATION
	##*===============================================
	[string]$installPhase = &#039;Post-Installation&#039;
	
	# Activate Office components (if running as a user)
	If ($CurrentLoggedOnUserSession -or $CurrentConsoleUserSession -or $RunAsActiveUser) {
		If (Test-Path -LiteralPath (Join-Path -Path $dirOffice -ChildPath &#039;Office16\OSPP.VBS&#039;) -PathType &#039;Leaf&#039;) {
    #		Show-InstallationProgress -StatusMessage &#039;Activating Microsoft Office components. This may take some time. Please wait...&#039;
			Execute-Process -Path &#039;cscript.exe&#039; -Parameters &quot;<code>&amp;quot;$dirOffice\Office16\OSPP.VBS</code>&quot; /ACT&quot; -WindowStyle Hidden
		}
	}

    # Create a shortcut for Skype for Business 2016 - this is a bug in the deployment from Microsoft
    New-Shortcut -Path &quot;$envProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2016\Skype for Business 2016.lnk&quot; -TargetPath &quot;$envProgramFilesX86\Microsoft Office\Office16\lync.exe&quot; -IconLocation &quot;$envProgramFilesX86\Microsoft Office\Office16\lync.exe&quot; -Description &#039;Skype for Business 2016&#039;

    ## Display a message at the end of the install
	If (-not $useDefaultMsi) { Show-InstallationPrompt -Message &#039;Hello Hooligan!! In order to use Office 2016, please restart your computer.&#039; -ButtonRightText &#039;OK&#039; -Icon Information -NoWait

	# Prompt for a restart (if running as a user, not installing components and not running on a server)
	#If ((-not $addComponentsOnly) -and ($deployMode -eq &#039;Interactive&#039;) -and (-not $IsServerOS)) {
	#	Show-InstallationRestartPrompt
	}
}
ElseIf ($deploymentType -ieq &#039;Uninstall&#039;)
{
	##*===============================================
	##* PRE-UNINSTALLATION
	##*===============================================
	[string]$installPhase = &#039;Pre-Uninstallation&#039;
	
	## Show Welcome Message, close applications that cause uninstall to fail
	Show-InstallationWelcome -CloseApps &#039;excel,groove,infopath,onenote,outlook,mspub,powerpnt,winword,winproj,visio&#039;
	
	## Show Progress Message (with the default message)
	Show-InstallationProgress -StatusMessage &#039;Uninstalling Office Professional 2016. This may take some time. Please wait...&#039;

	#Remove Skype for Buisness 2016 shortcut from Start Menu
    Remove-File -Path &#039;$envProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2016\Skype for Business 2016.lnk&#039;
	
	##*===============================================
	##* UNINSTALLATION
	##*===============================================
	[string]$installPhase = &#039;Uninstallation&#039;
    
    #Uninstall Office 2016 - It should keep Visio and Project intact if installed
	Execute-Process -Path &quot;cscript.exe&quot; -Parameters &quot;<code>&amp;quot;$dirSupportFiles\OffScrub_O16msi.vbs</code>&quot; ProPlus /S /Q /NoCancel&quot; -WindowStyle Hidden -IgnoreExitCodes &#039;1,2,3&#039;
	#Execute-Process -Path &quot;$dirFiles\Setup.exe&quot; -Parameters &quot;/CONFIGURE uninstall.xml&quot;
	
	##*===============================================
	##* POST-UNINSTALLATION
	##*===============================================
	[string]$installPhase = &#039;Post-Uninstallation&#039;
	
	## &lt;Perform Post-Uninstallation tasks here&gt;
}

##*===============================================
##* END SCRIPT BODY
##*===============================================

## Call the Exit-Script function to perform final cleanup operations
Exit-Script -ExitCode $mainExitCode

}
Catch {
[int32]$mainExitCode = 1
[string]$mainErrorMessage = "$(Resolve-Error)"
Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
Exit-Script -ExitCode $mainExitCode
}

I should add that if i add anything to setup.exe, like the following:

Execute-Process -Path “$dirFiles\Setup.exe” -Parameters “/adminfile “$dirFiles\Config\Office2016.MSP” /config “$dirFiles\ProPlus.WW\Config.xml”” -WindowStyle Hidden -IgnoreExitCodes ‘3010’

Fails! So i can’t even get it to install using this. The only install that works is the one i have above in the script, which is super frustrating!

Typically the .MSP file is put in the Updates folder, which if i run just setup.exe it does all the things my custom .MSP file is supposed to do.

Ok so I’m guessing the $dirFiles is filled with the Setup Files of Office 2016?

As far as I see it you need to delete the line

Execute-Process -Path "cscript.exe" -Parameters ""$dirSu...
Then Add this Line:
Execute-Process -Path "$dirFiles\Setup.exe" -Parameters "/uninstall ProPlus /config uninstall.xml"
You see the difference? Since the Office Setup.exe is a Tool to install or uninstall Office (in all its Versions), Visio, Project and Skype for Business you need to tell the Setup.exe what you'd like to uninstall.

About the Configfiles: I have put it right next to the Setup.exe of Office 2016, most People put it into the proplus.ww Folder since this was the original Place where it should be.

I Hope this helped…

About your MSP Problem:

The MSP only works if no part of Office 2016 is installed on your device. I was also confused why it doesnt work by putting it into the Updates folder but you really need to give the /adminfile Parameter to make sure it works. As soon as you have even the smalles shred of Office 2016 already on your system and you want to get more Parts of Office installed you’ll need a Config file that adds additional Parts of office (<OptionState Id=“WORDFiles” State=“local” Children=“force” /> and similar)

I was overall very annoyed by all those “click to run” Tutorials but no Tutorials about a “normal” distribution.

I wil lgive that a shot. I have tried multiple ways to install and uninstall.

The line with the

Execute-Process -Path “cscript.exe” -Parameters “"$dirSu…

This was me testing to see if i can use the Office 2016 OffScrub file to remove all of Office 2016. I would have thought it would work to completely gut Office, but that failed as well.

So I created a uninstall.xml file and put it in the root ($dirFiles) that has all the Office files and i will see if it works.

So even though i have this as my uninstall

Execute-Process -Path "$dirFiles\Setup.exe" -Parameters "/uninstall ProPlus /config uninstall.xml"

It still does this part:

Show-InstallationProgress -StatusMessage 'Installing Office Professional 2016. This may take some time. Please wait…' Execute-Process -Path "$dirFiles\Setup.exe" -WindowStyle Hidden -IgnoreExitCodes '3010'

Even though I have Deploy-Application.exe Uninstall setup, i get this started, but with the options to Add remove Features, Repair, Remove, Enter Product key.

I have no idea why it is just not running the uninstall portion!!! Grr…

So i have zero issues with install, but uninstall cannot function… i am about to say the hell with uninstall and just leave it. I am not sure if this is a toolkit issue in regards to it not running Uninstall or something else.

This is what the Toolkit log shows for Uninstall:

[Initialization] :: Installation is running in [Interactive] mode. PSAppDeployToolkit 3/29/2016 12:01:30 PM 1156 (0x0484)
[Initialization] :: Deployment type is [Uninstallation]. PSAppDeployToolkit 3/29/2016 12:01:30 PM 1156 (0x0484)
[Installation] :: Spin up progress dialog in a separate thread with message: [Installing Office Professional 2016. This may take some time. Please wait…]. Show-InstallationProgress 3/29/2016 12:01:30 PM 1156 (0x0484)
[Installation] :: [C:\WINDOWS\ccmcache\6\Files\Setup.exe] is a valid fully qualified path, continue. Execute-Process 3/29/2016 12:01:31 PM 1156 (0x0484)
[Installation] :: Working Directory is [C:\WINDOWS\ccmcache\6\Files]. Execute-Process 3/29/2016 12:01:31 PM 1156 (0x0484)
[Installation] :: Executing [C:\WINDOWS\ccmcache\6\Files\Setup.exe]… Execute-Process 3/29/2016 12:01:31 PM 1156 (0x0484)

I am convinced there is an issue with the toolkit somewhere. Even running Deploy-Application.ps1 Uninstall has it kick off the Installation.

I got everythign working now. It was actually the toolkit causing me headaches.
So i took a “normal” template and put what i needed and everything works. I believe the issue it kept getting hung up on was the Pre-Installation phase.

Appreciate all the help.