-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.ps1
30 lines (26 loc) · 1.18 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
# Run as administrator
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "Please run this script as Administrator!"
exit 1
}
$USER_BIN = "$env:USERPROFILE\bin"
$targetPath = "$USER_BIN\skipped-tests-finder"
# Remove the script if it exists
if (Test-Path -Path $targetPath) {
Write-Host "Removing skipped-tests-finder..."
Remove-Item -Path $targetPath -Force
Write-Host "Successfully removed skipped-tests-finder"
} else {
Write-Host "skipped-tests-finder is not installed in $USER_BIN"
}
# Remove bin directory from PATH if it's empty
if ((Get-ChildItem -Path $USER_BIN -Force | Measure-Object).Count -eq 0) {
Write-Host "Removing empty bin directory from PATH..."
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
$newPath = ($currentPath -split ";" | Where-Object { $_ -ne $USER_BIN }) -join ";"
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
$env:Path = $newPath
# Remove empty bin directory
Remove-Item -Path $USER_BIN -Force
Write-Host "Removed bin directory from PATH"
}