-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.ps1
31 lines (25 loc) · 1.17 KB
/
installer.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
$jsonUrl = "https://raw.githubusercontent.com/zix-rs/zix/refs/heads/main/zix.json"
try {
$json = Invoke-RestMethod -Uri $jsonUrl -Method GET
$latestVersion = $json."dist-version".latest
$latestUrl = $json.versions.$latestVersion.url
Write-Output $json
Write-Host "Latest available version: $latestVersion"
$TargetDir = "C:\Program Files\Zix"
$DownloadPath = Join-Path -Path $TargetDir -ChildPath "zx.exe"
$currentPath = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine)
if ($currentPath -split ";" -contains $TargetDir) {
Write-Host "Zix is already in PATH. Updating executable..."
} else {
Write-Host "Zix is not in PATH. Adding it now..."
[Environment]::SetEnvironmentVariable("PATH", "$currentPath;$TargetDir", [EnvironmentVariableTarget]::Machine)
Write-Host "Zix added to PATH."
}
if (-not (Test-Path -Path $TargetDir)) {
New-Item -ItemType Directory -Path $TargetDir -Force
}
Invoke-WebRequest -Uri $latestUrl -OutFile $DownloadPath
Write-Output "Zix successfully installed/updated."
} catch {
Write-Host "Error fetching registry information: $_"
}