|
# ============================================================= |
|
# Uninstall-ClaudeDesktop.ps1 |
|
# Completely removes Claude Desktop and ALL associated files |
|
# including the Cowork VM bundle that the official uninstaller |
|
# leaves behind. |
|
# |
|
# Run in PowerShell as Administrator: |
|
# Right-click PowerShell -> "Run as Administrator" |
|
# .\Uninstall-ClaudeDesktop.ps1 |
|
# ============================================================= |
|
|
|
$ErrorActionPreference = 'SilentlyContinue' |
|
|
|
function Write-Step { param($msg) Write-Host "`n>> $msg" -ForegroundColor Cyan } |
|
function Write-OK { param($msg) Write-Host " [OK] $msg" -ForegroundColor Green } |
|
function Write-Skip { param($msg) Write-Host " [SKIP] $msg" -ForegroundColor DarkGray } |
|
function Write-Warn { param($msg) Write-Host " [WARN] $msg" -ForegroundColor Yellow } |
|
function Write-Fail { param($msg) Write-Host " [FAIL] $msg" -ForegroundColor Red } |
|
|
|
function Remove-IfExists { |
|
param([string]$Path, [string]$Label) |
|
if (Test-Path $Path) { |
|
try { |
|
Remove-Item -Path $Path -Recurse -Force -ErrorAction Stop |
|
Write-OK "Deleted: $Path" |
|
} catch { |
|
Write-Fail "Could not delete $Path — $($_.Exception.Message)" |
|
} |
|
} else { |
|
Write-Skip "Not found: $Path" |
|
} |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "============================================================" -ForegroundColor Magenta |
|
Write-Host " Claude Desktop — Full Uninstaller" -ForegroundColor Magenta |
|
Write-Host "============================================================" -ForegroundColor Magenta |
|
|
|
|
|
# ------------------------------------------------------------------ |
|
# 1. Kill running Claude processes |
|
# ------------------------------------------------------------------ |
|
Write-Step "Stopping Claude processes..." |
|
|
|
$claudeProcs = Get-Process | Where-Object { $_.ProcessName -like "*claude*" -or $_.ProcessName -like "*cowork*" } |
|
if ($claudeProcs) { |
|
$claudeProcs | Stop-Process -Force |
|
Start-Sleep -Seconds 2 |
|
Write-OK "Stopped $($claudeProcs.Count) process(es)" |
|
} else { |
|
Write-Skip "No Claude processes running" |
|
} |
|
|
|
|
|
# ------------------------------------------------------------------ |
|
# 2. Stop and remove the Cowork VM service |
|
# ------------------------------------------------------------------ |
|
Write-Step "Removing Cowork VM service..." |
|
|
|
$svc = Get-Service -Name "CoworkVMService" -ErrorAction SilentlyContinue |
|
if ($svc) { |
|
Stop-Service -Name "CoworkVMService" -Force |
|
sc.exe delete "CoworkVMService" | Out-Null |
|
Write-OK "Removed CoworkVMService" |
|
} else { |
|
Write-Skip "CoworkVMService not found" |
|
} |
|
|
|
|
|
# ------------------------------------------------------------------ |
|
# 3. Run the official uninstaller (MSIX / Squirrel) |
|
# ------------------------------------------------------------------ |
|
Write-Step "Running official uninstaller..." |
|
|
|
# Try MSIX / Windows Store package first |
|
$msix = Get-AppxPackage -Name "*Claude*" -ErrorAction SilentlyContinue |
|
if ($msix) { |
|
Remove-AppxPackage -Package $msix.PackageFullName -ErrorAction SilentlyContinue |
|
Write-OK "Removed MSIX package: $($msix.Name)" |
|
} else { |
|
Write-Skip "No MSIX package found" |
|
} |
|
|
|
# Try Squirrel / classic installer |
|
$squirrelUninstaller = "$env:LOCALAPPDATA\AnthropicClaude\Update.exe" |
|
if (Test-Path $squirrelUninstaller) { |
|
Write-OK "Found Squirrel uninstaller — running..." |
|
Start-Process -FilePath $squirrelUninstaller -ArgumentList "--uninstall" -Wait |
|
Start-Sleep -Seconds 3 |
|
} else { |
|
Write-Skip "Squirrel uninstaller not found" |
|
} |
|
|
|
|
|
# ------------------------------------------------------------------ |
|
# 4. Delete all AppData folders (the big ones the uninstaller misses) |
|
# ------------------------------------------------------------------ |
|
Write-Step "Removing AppData folders..." |
|
|
|
$foldersToRemove = @( |
|
# Roaming — conversation history, vm_bundles (Cowork), settings, cache |
|
"$env:APPDATA\Claude", |
|
|
|
# Local — main app installation directory |
|
"$env:LOCALAPPDATA\AnthropicClaude", |
|
"$env:LOCALAPPDATA\Claude", |
|
|
|
# MSIX sandboxed package data |
|
"$env:LOCALAPPDATA\Packages\Claude_pzs8sxjxfjjc", # common package family name |
|
"$env:LOCALAPPDATA\Packages\AnthropicPBC.Claude_*", |
|
|
|
# Windows app alias that hijacks the 'claude' command in terminals |
|
"$env:LOCALAPPDATA\Microsoft\WindowsApps\Claude.exe", |
|
"$env:LOCALAPPDATA\Microsoft\WindowsApps\claude.exe" |
|
) |
|
|
|
foreach ($path in $foldersToRemove) { |
|
# Expand wildcards for Packages entries |
|
$resolved = Resolve-Path $path -ErrorAction SilentlyContinue |
|
if ($resolved) { |
|
foreach ($r in $resolved) { Remove-IfExists -Path $r.Path -Label $r.Path } |
|
} else { |
|
Remove-IfExists -Path $path -Label $path |
|
} |
|
} |
|
|
|
|
|
# ------------------------------------------------------------------ |
|
# 5. Remove shortcuts |
|
# ------------------------------------------------------------------ |
|
Write-Step "Removing shortcuts..." |
|
|
|
$shortcuts = @( |
|
"$env:USERPROFILE\Desktop\Claude.lnk", |
|
"$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Claude.lnk", |
|
"$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Anthropic\Claude.lnk", |
|
"$env:ALLUSERSPROFILE\Microsoft\Windows\Start Menu\Programs\Claude.lnk" |
|
) |
|
|
|
foreach ($s in $shortcuts) { Remove-IfExists -Path $s -Label $s } |
|
|
|
|
|
# ------------------------------------------------------------------ |
|
# 6. Clean up registry entries |
|
# ------------------------------------------------------------------ |
|
Write-Step "Cleaning registry..." |
|
|
|
$registryKeys = @( |
|
"HKCU:\Software\Anthropic", |
|
"HKCU:\Software\Classes\claude", # URL handler |
|
"HKLM:\Software\Anthropic", |
|
"HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\claude", |
|
"HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\{*Claude*}" |
|
) |
|
|
|
foreach ($key in $registryKeys) { |
|
if ($key -like "*{*}*") { |
|
# Wildcard search in uninstall hive |
|
$matches = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall" | |
|
Where-Object { $_.Name -like "*Claude*" } |
|
foreach ($m in $matches) { |
|
Remove-IfExists -Path "Registry::$($m.Name)" -Label $m.Name |
|
} |
|
} else { |
|
Remove-IfExists -Path $key -Label $key |
|
} |
|
} |
|
|
|
|
|
# ------------------------------------------------------------------ |
|
# 7. Final size check — warn if anything large remains |
|
# ------------------------------------------------------------------ |
|
Write-Step "Checking for any remaining Claude data..." |
|
|
|
$checkPaths = @( |
|
"$env:APPDATA\Claude", |
|
"$env:LOCALAPPDATA\AnthropicClaude", |
|
"$env:LOCALAPPDATA\Claude" |
|
) |
|
|
|
$anyLeft = $false |
|
foreach ($p in $checkPaths) { |
|
if (Test-Path $p) { |
|
$size = (Get-ChildItem $p -Recurse -ErrorAction SilentlyContinue | |
|
Measure-Object -Property Length -Sum).Sum |
|
$sizeMB = [math]::Round($size / 1MB, 1) |
|
Write-Warn "Still exists ($sizeMB MB): $p" |
|
$anyLeft = $true |
|
} |
|
} |
|
|
|
if (-not $anyLeft) { |
|
Write-OK "All Claude Desktop folders are gone" |
|
} |
|
|
|
|
|
# ------------------------------------------------------------------ |
|
# Done |
|
# ------------------------------------------------------------------ |
|
Write-Host "" |
|
Write-Host "============================================================" -ForegroundColor Magenta |
|
if ($anyLeft) { |
|
Write-Host " Done (with warnings — see above)" -ForegroundColor Yellow |
|
Write-Host " Some files may be locked. Try rebooting and re-running." -ForegroundColor Yellow |
|
} else { |
|
Write-Host " Claude Desktop fully removed!" -ForegroundColor Green |
|
} |
|
Write-Host "============================================================" -ForegroundColor Magenta |
|
Write-Host "" |