-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcxpost-uninstall.ps1
More file actions
63 lines (55 loc) · 1.99 KB
/
Copy pathcxpost-uninstall.ps1
File metadata and controls
63 lines (55 loc) · 1.99 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
# CXPost Uninstaller for Windows
# Copyright (c) Nikolaos Protopapas. All rights reserved.
# Licensed under the MIT License.
$installDir = "$env:LOCALAPPDATA\CXPost"
$configDir = "$env:APPDATA\CXPost"
Write-Host "CXPost Uninstaller" -ForegroundColor Cyan
Write-Host ""
# Remove binary
if (Test-Path "$installDir\cxpost.exe") {
Remove-Item "$installDir\cxpost.exe" -Force
Write-Host "Removed $installDir\cxpost.exe" -ForegroundColor Green
} else {
Write-Host "Binary not found at $installDir\cxpost.exe"
}
# Ask about config
if (Test-Path $configDir) {
Write-Host ""
Write-Host "Config directory: $configDir"
Write-Host " Contains: config.yaml, credentials"
$confirm = Read-Host " Remove config? [y/N]"
if ($confirm -eq 'y' -or $confirm -eq 'Y') {
Remove-Item $configDir -Recurse -Force
Write-Host " Removed $configDir" -ForegroundColor Green
} else {
Write-Host " Kept $configDir"
}
}
# Ask about data
$dataDir = "$env:LOCALAPPDATA\CXPost\data"
if (Test-Path $dataDir) {
Write-Host ""
Write-Host "Data directory: $dataDir"
Write-Host " Contains: mail.db, contacts.db (cached emails)"
$confirm = Read-Host " Remove data? [y/N]"
if ($confirm -eq 'y' -or $confirm -eq 'Y') {
Remove-Item $dataDir -Recurse -Force
Write-Host " Removed $dataDir" -ForegroundColor Green
} else {
Write-Host " Kept $dataDir"
}
}
# Remove install dir if empty
if ((Test-Path $installDir) -and (Get-ChildItem $installDir | Measure-Object).Count -eq 0) {
Remove-Item $installDir -Force
}
# Remove from PATH
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -like "*$installDir*") {
$newPath = ($userPath -split ';' | Where-Object { $_ -ne $installDir }) -join ';'
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
Write-Host ""
Write-Host "Removed $installDir from PATH" -ForegroundColor Green
}
Write-Host ""
Write-Host "CXPost uninstalled." -ForegroundColor Green