- Official Post
Sometimes you have as example Office 365 installed but with several language packs and proofing tools etc. Than it is a pain in the ass to remove every single installation.
A more fast and smooth way provides this script here
PowerShell
# Start the stopwatch at the very beginning
$Stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
# 1. Enforce PowerShell as Administrator
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Error "Please run this PowerShell script as an Administrator!"
Exit
}
# Dynamically determine the directory where this script is located
$CurrentDir = $PSScriptRoot
if ([string]::IsNullOrEmpty($CurrentDir)) { $CurrentDir = Get-Location }
Write-Host "=== Starting Office Uninstall from $CurrentDir (All Languages) ===" -ForegroundColor Cyan
# 2. Check if setup.exe exists in the current directory
if (-not (Test-Path "$CurrentDir\setup.exe")) {
Write-Error "ERROR: setup.exe was not found in $CurrentDir!"
Exit
}
# 3. Create the XML configuration file dynamically
$XmlContent = @"
<Configuration>
<Remove All="TRUE">
<Language ID="all" />
</Remove>
<Property Name="FORCEAPPSHUTDOWN" Value="TRUE" />
<Display Level="None" AcceptEULA="TRUE" />
</Configuration>
"@
$XmlFile = "$CurrentDir\uninstall_office.xml"
$XmlContent | Out-File -FilePath $XmlFile -Encoding ascii
# 4. Trigger the uninstallation
Write-Host "Uninstalling Office in the background. Please wait..." -ForegroundColor Yellow
Write-Host "(Any open Office applications will be closed automatically.)" -ForegroundColor DarkGray
$Process = Start-Process -FilePath "$CurrentDir\setup.exe" -ArgumentList "/configure `"$XmlFile`"" -Wait -PassThru
# Stop the stopwatch before printing the final banner
$Stopwatch.Stop()
$ElapsedTime = "{0:mm}m {0:ss}s" -f $Stopwatch.Elapsed
# 5. Evaluate the result and Exit Code
if ($Process.ExitCode -eq 0) {
Write-Host ""
Write-Host "===================================================================" -ForegroundColor Green
Write-Host " SUCCESS: Office and all language packs have been removed! " -ForegroundColor Green
Write-Host " Total Execution Time: $ElapsedTime" -ForegroundColor Green
Write-Host "===================================================================" -ForegroundColor Green
Remove-Item -Force $XmlFile -ErrorAction SilentlyContinue
} else {
Remove-Item -Force $XmlFile -ErrorAction SilentlyContinue
$OfficeService = Get-Service -Name "ClickToRunSvc" -ErrorAction SilentlyContinue
$OfficeRegistry = Test-Path "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun"
if (-not $OfficeService -and -not $OfficeRegistry) {
Write-Host ""
Write-Host "Notice: No installed Office product was detected on this system." -ForegroundColor DarkYellow
Write-Host "The uninstallation process has been skipped." -ForegroundColor DarkYellow
Write-Host "Total Execution Time: $ElapsedTime" -ForegroundColor DarkYellow
} else {
Write-Error "An error occurred during the Office uninstallation. ExitCode: $($Process.ExitCode)"
Write-Host "Total Execution Time: $ElapsedTime" -ForegroundColor Red
}
}
Display More