mirror of
https://github.com/Baipyrus/ProxySwitcher.git
synced 2024-12-27 05:01:45 +00:00
adjusting installation script to download and expand release archive
This commit is contained in:
parent
0f6b64c379
commit
b297828c80
32
install.ps1
32
install.ps1
@ -29,33 +29,12 @@ if ($startupDir -ne $destinationDir)
|
|||||||
Set-Location $programDir
|
Set-Location $programDir
|
||||||
$programPath = "$destinationDir\$programDir"
|
$programPath = "$destinationDir\$programDir"
|
||||||
|
|
||||||
# Download functional files from github as-is
|
# Download release files from github as-is
|
||||||
Write-Host "Downloading program into local directory..." -ForegroundColor Cyan
|
Write-Host "Downloading program into local directory..." -ForegroundColor Cyan
|
||||||
function DownloadFile
|
Invoke-RestMethod https://github.com/Baipyrus/ProxySwitcher/releases/latest/download/ProxySwitcher.zip -OutFile $env:TMP
|
||||||
{
|
|
||||||
param (
|
|
||||||
[string]$url
|
|
||||||
)
|
|
||||||
|
|
||||||
$fileName = $url.Split("/")[-1]
|
# Expand Archive to program directory
|
||||||
Invoke-RestMethod $url -OutFile $fileName
|
Expand-Archive "$env:TMP\ProxySwitcher.zip" -DestinationPath $programPath
|
||||||
}
|
|
||||||
DownloadFile -url https://github.com/Baipyrus/ProxySwitcher/releases/latest/download/ProxySwitcher.exe
|
|
||||||
DownloadFile -url https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/configs.json
|
|
||||||
DownloadFile -url https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/run.ps1
|
|
||||||
|
|
||||||
# Create assets directory and relocate
|
|
||||||
Write-Host "Downloading assets into local directory..." -ForegroundColor Cyan
|
|
||||||
$assetsDir = "assets"
|
|
||||||
if (-not (Test-Path $assetsDir))
|
|
||||||
{ New-Item -ItemType Directory -Path $assetsDir | Out-Null
|
|
||||||
}
|
|
||||||
Set-Location $assetsDir
|
|
||||||
$assetPath = "$programPath\assets\ICON_Enabled.ico"
|
|
||||||
|
|
||||||
# Download asset files from github
|
|
||||||
DownloadFile -url https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/assets/ICON_Disabled.ico
|
|
||||||
DownloadFile -url https://raw.githubusercontent.com/Baipyrus/ProxySwitcher/main/assets/ICON_Enabled.ico
|
|
||||||
|
|
||||||
# Add program to PATH for cli application
|
# Add program to PATH for cli application
|
||||||
$userpath = [System.Environment]::GetEnvironmentVariable("PATH", "User")
|
$userpath = [System.Environment]::GetEnvironmentVariable("PATH", "User")
|
||||||
@ -64,14 +43,13 @@ $userpath = $userpath + ";$programDir"
|
|||||||
|
|
||||||
# Create Startmenu Shortcut
|
# Create Startmenu Shortcut
|
||||||
Write-Host "Creating shortcuts for easy access..." -ForegroundColor Cyan
|
Write-Host "Creating shortcuts for easy access..." -ForegroundColor Cyan
|
||||||
$assetsDir = "assets"
|
|
||||||
$shell = New-Object -comObject WScript.Shell
|
$shell = New-Object -comObject WScript.Shell
|
||||||
$shortcutPath = "$startmenuDir\Proxy Switcher.lnk"
|
$shortcutPath = "$startmenuDir\Proxy Switcher.lnk"
|
||||||
$shortcut = $shell.CreateShortcut($shortcutPath)
|
$shortcut = $shell.CreateShortcut($shortcutPath)
|
||||||
$shortcut.TargetPath = $powershellPath
|
$shortcut.TargetPath = $powershellPath
|
||||||
$shortcut.WorkingDirectory = $programPath
|
$shortcut.WorkingDirectory = $programPath
|
||||||
$shortcut.Arguments = "-ExecutionPolicy Bypass -NonInteractive -NoProfile -WindowStyle Hidden -File ""$programPath\run.ps1"""
|
$shortcut.Arguments = "-ExecutionPolicy Bypass -NonInteractive -NoProfile -WindowStyle Hidden -File ""$programPath\run.ps1"""
|
||||||
$shortcut.IconLocation = $assetPath
|
$shortcut.IconLocation = "$programPath\assets\ICON_Enabled.ico"
|
||||||
$shortcut.WindowStyle = 7
|
$shortcut.WindowStyle = 7
|
||||||
$shortcut.Save()
|
$shortcut.Save()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user