-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.ps1
More file actions
70 lines (62 loc) · 2.22 KB
/
uninstall.ps1
File metadata and controls
70 lines (62 loc) · 2.22 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
#Requires -Version 5.1
$ErrorActionPreference = 'Stop'
Write-Host ""
Write-Host " syncfu uninstaller" -ForegroundColor White
Write-Host ""
$Removed = 0
# --- Stop running processes ---
$Procs = Get-Process -Name "syncfu" -ErrorAction SilentlyContinue
if ($Procs) {
Write-Host "info " -ForegroundColor Green -NoNewline
Write-Host "Stopping syncfu processes..."
$Procs | Stop-Process -Force
Start-Sleep -Seconds 1
}
# --- Remove desktop app (NSIS install location) ---
$AppDir = Join-Path $env:LOCALAPPDATA "syncfu"
if (Test-Path $AppDir) {
$Uninstaller = Join-Path $AppDir "Uninstall syncfu.exe"
if (Test-Path $Uninstaller) {
Write-Host "info " -ForegroundColor Green -NoNewline
Write-Host "Running desktop app uninstaller..."
Start-Process -FilePath $Uninstaller -ArgumentList "/S" -Wait -NoNewWindow
} else {
Remove-Item -Recurse -Force $AppDir
}
Write-Host "info " -ForegroundColor Green -NoNewline
Write-Host "Removed desktop app"
$Removed++
}
# --- Remove CLI binary ---
$CliDir = Join-Path $HOME ".syncfu\bin"
if (Test-Path (Join-Path $CliDir "syncfu.exe")) {
Remove-Item -Force (Join-Path $CliDir "syncfu.exe")
Write-Host "info " -ForegroundColor Green -NoNewline
Write-Host "Removed $CliDir\syncfu.exe"
$Removed++
}
# --- Clean up ~/.syncfu directory ---
$SyncfuDir = Join-Path $HOME ".syncfu"
if (Test-Path $SyncfuDir) {
Remove-Item -Recurse -Force $SyncfuDir
Write-Host "info " -ForegroundColor Green -NoNewline
Write-Host "Removed ~/.syncfu"
}
# --- Remove from PATH ---
$UserPath = [Environment]::GetEnvironmentVariable('Path', 'User')
if ($UserPath -and $UserPath -like '*\.syncfu\bin*') {
$NewPath = ($UserPath -split ';' | Where-Object { $_ -notlike '*\.syncfu\bin*' }) -join ';'
[Environment]::SetEnvironmentVariable('Path', $NewPath, 'User')
Write-Host "info " -ForegroundColor Green -NoNewline
Write-Host "Removed syncfu from PATH"
}
# --- Done ---
Write-Host ""
if ($Removed -gt 0) {
Write-Host "info " -ForegroundColor Green -NoNewline
Write-Host "syncfu has been uninstalled."
} else {
Write-Host "warn " -ForegroundColor Yellow -NoNewline
Write-Host "No syncfu installation found."
}
Write-Host ""