-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds install and uninstall scripts for windows
- Loading branch information
1 parent
c987523
commit eedf869
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,3 +145,5 @@ archives: | |
- README.md | ||
- autoproxy.config | ||
- scripts/* | ||
- install.ps1 | ||
- uninstall.ps1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 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 | ||
$binDir = "bin" | ||
$configDir = "." | ||
$installDir = "C:\Program Files\IITJ Autoproxy" | ||
$configInstallDir = "C:\ProgramData\IITJ Autoproxy" | ||
|
||
# Create installation directories if they don't exist | ||
if (-Not (Test-Path $installDir)) { | ||
New-Item -Path $installDir -ItemType Directory | ||
} | ||
|
||
if (-Not (Test-Path $configInstallDir)) { | ||
New-Item -Path $configInstallDir -ItemType Directory | ||
} | ||
|
||
# Copy binaries | ||
Copy-Item -Path "$binDir\*" -Destination $installDir -Force | ||
|
||
# Copy example config, README, and LICENSE to config folder | ||
Copy-Item -Path "$configDir\autoproxy.config" -Destination $configInstallDir -Force | ||
Copy-Item -Path "$configDir\README.md" -Destination $configInstallDir -Force | ||
Copy-Item -Path "$configDir\LICENSE" -Destination $configInstallDir -Force | ||
|
||
# Add to PATH environment variable | ||
$envPath = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) | ||
if (-Not ($envPath -like "*$installDir*")) { | ||
[Environment]::SetEnvironmentVariable("Path", $envPath + ";$installDir", [EnvironmentVariableTarget]::Machine) | ||
} | ||
|
||
Write-Host "Installation completed successfully!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# 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" | ||
|
||
# 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 | ||
} | ||
|
||
# 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 completed successfully!" |