-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoproxy-uninstall.ps1
34 lines (28 loc) · 1.34 KB
/
autoproxy-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
# Ensure the script is run as Administrator
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Host "This script must be run as an Administrator. Restarting as administrator..."
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File $($MyInvocation.MyCommand.Path)" -Verb RunAs
exit
}
# Define directories
$installDir = "C:\Program Files\IITJ Autoproxy"
$configInstallDir = "C:\ProgramData\IITJ Autoproxy"
$homeDir = $env:USERPROFILE
# Remove binaries
if (Test-Path $installDir) {
Remove-Item -Path "$installDir\*" -Force
Remove-Item -Path $installDir -Force
}
# Remove config files, README, and LICENSE
if (Test-Path $configInstallDir) {
Remove-Item -Path "$configInstallDir\*" -Force
Remove-Item -Path $configInstallDir -Force
}
if (Test-Path $homeDir) {
Remove-Item -Path "$homeDir\.autoproxy.*" -Force
}
# Remove from PATH environment variable
$envPath = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine)
$newEnvPath = ($envPath.Split(';') | Where-Object { $_ -ne $installDir }) -join ';'
[Environment]::SetEnvironmentVariable("Path", $newEnvPath, [EnvironmentVariableTarget]::Machine)
Write-Host "Uninstallation of IITJ Autoproxy completed successfully!"