-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.ps1
More file actions
59 lines (46 loc) · 1.63 KB
/
Copy pathuninstall.ps1
File metadata and controls
59 lines (46 loc) · 1.63 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
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
# OpenCoder uninstaller (Windows)
# Usage: irm https://raw.githubusercontent.com/<owner>/<repo>/main/uninstall.ps1 | iex
$InstallDir = Join-Path $env:LOCALAPPDATA "OpenCoder"
$StartMenuShortcutPath = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs\OpenCoder.lnk"
function Info([string]$Message) {
Write-Host ":: $Message" -ForegroundColor Cyan
}
function Warn([string]$Message) {
Write-Host ":: $Message" -ForegroundColor Yellow
}
function Remove-FromUserPath([string]$PathEntry) {
$current = [Environment]::GetEnvironmentVariable("Path", "User")
if (-not $current) {
return
}
$normalizedTarget = $PathEntry.Trim().TrimEnd('\').ToLowerInvariant()
$parts = $current.Split(";") | Where-Object {
$candidate = $_.Trim()
if (-not $candidate) {
return $false
}
$candidate.TrimEnd('\').ToLowerInvariant() -ne $normalizedTarget
}
$updated = $parts -join ";"
[Environment]::SetEnvironmentVariable("Path", $updated, "User")
}
$removedAny = $false
if (Test-Path $StartMenuShortcutPath) {
Remove-Item -Force -Path $StartMenuShortcutPath
Info "Removed Start Menu shortcut: $StartMenuShortcutPath"
$removedAny = $true
}
if (Test-Path $InstallDir) {
Remove-Item -Recurse -Force -Path $InstallDir
Info "Removed install directory: $InstallDir"
$removedAny = $true
}
Remove-FromUserPath -PathEntry $InstallDir
Info "Removed OpenCoder install path from user PATH (if present)."
if (-not $removedAny) {
Warn "No OpenCoder installation artifacts found."
}
Write-Host ""
Write-Host "OpenCoder uninstall finished." -ForegroundColor Green