-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
34 lines (26 loc) · 1.02 KB
/
install.ps1
File metadata and controls
34 lines (26 loc) · 1.02 KB
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
$ErrorActionPreference = "Stop"
$Repo = "madLinux7/dstimer"
$Bin = "dstimer"
$InstallDir = "$env:LOCALAPPDATA\Programs\$Bin"
# Resolve latest release tag
$Release = Invoke-RestMethod "https://api.github.com/repos/$Repo/releases/latest"
$Tag = $Release.tag_name
if (-not $Tag) {
Write-Error "Could not determine latest release tag."
exit 1
}
$Url = "https://github.com/$Repo/releases/download/$Tag/$Bin.exe"
Write-Host "Installing $Bin $Tag (windows/x86_64)..."
# Download
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
$Dest = "$InstallDir\$Bin.exe"
Invoke-WebRequest -Uri $Url -OutFile $Dest
Write-Host "Installed to $Dest"
# Add to PATH for current user if not already present
$UserPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($UserPath -notlike "*$InstallDir*") {
[Environment]::SetEnvironmentVariable("PATH", "$UserPath;$InstallDir", "User")
Write-Host ""
Write-Host " Added $InstallDir to your PATH."
Write-Host " Restart your terminal for the change to take effect."
}