-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall-windows.ps1
More file actions
65 lines (54 loc) · 2.05 KB
/
uninstall-windows.ps1
File metadata and controls
65 lines (54 loc) · 2.05 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
<#
.SYNOPSIS
Uninstall Python-NoAdmin on Windows.
.DESCRIPTION
Removes the Python-NoAdmin installation directory and cleans up
user PATH environment variable entries.
#>
param(
[switch]$Force
)
$ErrorActionPreference = "Stop"
$InstallDir = "$env:USERPROFILE\.python-nonadmin"
Write-Host ""
Write-Host "============================================" -ForegroundColor Cyan
Write-Host " Python-NoAdmin Uninstaller" -ForegroundColor Cyan
Write-Host "============================================" -ForegroundColor Cyan
Write-Host ""
# Check if installed
if (-not (Test-Path $InstallDir)) {
Write-Host "[WARNING] Installation not found at: $InstallDir" -ForegroundColor Yellow
exit 0
}
# Confirm unless -Force
if (-not $Force) {
$response = Read-Host "This will remove Python-NoAdmin from $InstallDir. Continue? [y/N]"
if ($response -notmatch '^[Yy]') {
Write-Host "[INFO] Uninstallation cancelled." -ForegroundColor Cyan
exit 0
}
}
# Remove installation directory
Write-Host "[INFO] Removing installation directory..." -ForegroundColor Cyan
try {
Remove-Item -Recurse -Force $InstallDir
Write-Host "[SUCCESS] Removed: $InstallDir" -ForegroundColor Green
} catch {
Write-Host "[ERROR] Failed to remove installation: $_" -ForegroundColor Red
exit 1
}
# Clean PATH
Write-Host "[INFO] Cleaning user PATH..." -ForegroundColor Cyan
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
$pathParts = $currentPath -split ';' | Where-Object { $_ -notlike "*python-nonadmin*" }
$newPath = $pathParts -join ';'
if ($newPath -ne $currentPath) {
[Environment]::SetEnvironmentVariable("PATH", $newPath, "User")
Write-Host "[SUCCESS] Removed python-nonadmin entries from user PATH" -ForegroundColor Green
} else {
Write-Host "[INFO] No python-nonadmin entries found in user PATH" -ForegroundColor Cyan
}
Write-Host ""
Write-Host "[SUCCESS] Python-NoAdmin has been uninstalled." -ForegroundColor Green
Write-Host "[INFO] Restart your terminal for PATH changes to take effect." -ForegroundColor Cyan
Write-Host ""