-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathuninstall-windows.ps1
More file actions
91 lines (78 loc) · 3.33 KB
/
uninstall-windows.ps1
File metadata and controls
91 lines (78 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Deadlock API Ingest - Uninstall Script
# This script removes the application and all related components
param(
[switch]$Silent
)
$AppName = "deadlock-api-ingest"
$InstallDir = Join-Path -Path $env:LOCALAPPDATA -ChildPath $AppName
if (-not $Silent) {
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Deadlock API Ingest - Uninstaller" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "This will remove:" -ForegroundColor Yellow
Write-Host " - All scheduled tasks (current and old versions)" -ForegroundColor White
Write-Host " - Running processes" -ForegroundColor White
Write-Host " - Desktop shortcuts" -ForegroundColor White
Write-Host " - Installation directory: $InstallDir" -ForegroundColor White
Write-Host ""
$confirmation = Read-Host "Continue with uninstallation? (Y/N)"
if ($confirmation -ne 'Y' -and $confirmation -ne 'y') {
Write-Host "Uninstallation cancelled." -ForegroundColor Yellow
exit 0
}
Write-Host ""
}
Write-Host "Uninstalling Deadlock API Ingest..." -ForegroundColor Yellow
Write-Host ""
# Stop and remove all scheduled tasks (current and old versions)
Write-Host "Removing scheduled tasks..." -ForegroundColor Cyan
$tasksToRemove = @(
"$AppName",
"$AppName-Watchdog",
"$AppName-updater"
)
foreach ($taskName in $tasksToRemove) {
$task = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
if ($task) {
Write-Host " - Removing task: $taskName" -ForegroundColor Gray
Stop-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue
}
}
# Stop any running process
Write-Host "Stopping running processes..." -ForegroundColor Cyan
$processes = Get-Process -Name $AppName -ErrorAction SilentlyContinue
if ($processes) {
Write-Host " - Stopping $($processes.Count) process(es)" -ForegroundColor Gray
Stop-Process -Name $AppName -Force -ErrorAction SilentlyContinue
}
# Remove desktop shortcuts
Write-Host "Removing desktop shortcuts..." -ForegroundColor Cyan
$shortcutPaths = @(
"$env:USERPROFILE\Desktop\$AppName*.lnk",
"$env:USERPROFILE\OneDrive\Desktop\$AppName*.lnk"
)
$allShortcuts = $shortcutPaths | ForEach-Object { Get-Item $_ -ErrorAction SilentlyContinue }
if ($allShortcuts) {
Write-Host " - Removing $(@($allShortcuts).Count) shortcut(s)" -ForegroundColor Gray
$shortcutPaths | ForEach-Object { Remove-Item $_ -Force -ErrorAction SilentlyContinue }
}
# Remove installation directory
Write-Host "Removing installation directory..." -ForegroundColor Cyan
if (Test-Path $InstallDir) {
Write-Host " - Removing: $InstallDir" -ForegroundColor Gray
Set-Location $env:TEMP
Start-Sleep -Seconds 1
Remove-Item $InstallDir -Recurse -Force -ErrorAction SilentlyContinue
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Green
Write-Host " Uninstallation Complete!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host ""
if (-not $Silent) {
Write-Host "Press any key to exit..." -ForegroundColor Gray
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}