-
-
Notifications
You must be signed in to change notification settings - Fork 254
/
Copy pathuninstall.ps1
69 lines (59 loc) · 2.83 KB
/
uninstall.ps1
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
param(
[switch]
$AllUsers
)
function FolderIsInPATH($Path_to_directory) {
return ([Environment]::GetEnvironmentVariable("PATH", "User") -split ';').TrimEnd('\') -contains $Path_to_directory.TrimEnd('\')
}
Write-Host -ForegroundColor DarkRed " ______ __ __ "
Write-Host -ForegroundColor Red " / \ / |/ | "
Write-Host -ForegroundColor DarkYellow " _______ __ __ ______ ______ ______ /`$`$`$`$`$`$ |`$`$/ `$`$ | ______ "
Write-Host -ForegroundColor Yellow " / |/ | / | / \ / \ / \ `$`$ |_ `$`$/ / |`$`$ | / \ "
Write-Host -ForegroundColor DarkGreen "/`$`$`$`$`$`$`$/ `$`$ | `$`$ |/`$`$`$`$`$`$ |/`$`$`$`$`$`$ |/`$`$`$`$`$`$ |`$`$ | `$`$ |`$`$ |/`$`$`$`$`$`$ |"
Write-Host -ForegroundColor Green "`$`$ \ `$`$ | `$`$ |`$`$ | `$`$ |`$`$ `$`$ |`$`$ | `$`$/ `$`$`$`$/ `$`$ |`$`$ |`$`$ `$`$ |"
Write-Host -ForegroundColor DarkBlue " `$`$`$`$`$`$ |`$`$ \__`$`$ |`$`$ |__`$`$ |`$`$`$`$`$`$`$`$/ `$`$ | `$`$ | `$`$ |`$`$ |`$`$`$`$`$`$`$`$/ "
Write-Host -ForegroundColor Blue " `$`$/ `$`$ `$`$/ `$`$ `$`$/ `$`$ |`$`$ | `$`$ | `$`$ |`$`$ |`$`$ |"
Write-Host -ForegroundColor DarkMagenta "`$`$`$`$`$`$`$/ `$`$`$`$`$`$/ `$`$`$`$`$`$`$/ `$`$`$`$`$`$`$/ `$`$/ `$`$/ `$`$/ `$`$/ `$`$`$`$`$`$`$/ "
Write-Host -ForegroundColor Magenta " `$`$ | "
Write-Host -ForegroundColor DarkRed " `$`$ | "
Write-Host -ForegroundColor Red " `$`$/ "
Write-Host ""
$package = "superfile"
$version = "1.1.3"
$installInstructions = @'
This uninstaller is only available for Windows.
'@
if ($IsMacOS) {
Write-Host "$installInstructions"
exit
}
if ($IsLinux) {
Write-Host "$installInstructions"
exit
}
Write-Host "Removing folder..."
$superfileProgramPath = [Environment]::GetFolderPath("LocalApplicationData") + "\Programs\superfile"
try {
if (Test-Path $superfileProgramPath) {
Remove-Item -Path $superfileProgramPath -Recurse -Force
}
}
catch {
Write-Host "An error occurred: $_"
exit
}
Write-Host "Removing environment path..."
try {
if (FolderIsInPATH "$superfileProgramPath\") {
$envPath = [Environment]::GetEnvironmentVariable("PATH", "User")
$updatedPath =($envPath.Split(';') | Where-Object { $_ -ne "$superfileProgramPath" }) -join ';'
[Environment]::SetEnvironmentVariable("PATH", $updatedPath, "User")
}
}
catch {
Write-Host "An error occurred: $_"
exit
}
Write-Host @'
Uninstall Done!
'@