dsr/install.ps1

49 lines
1.9 KiB
PowerShell
Raw Permalink Normal View History

2024-05-17 19:25:09 +02:00
param (
2024-05-17 19:47:34 +02:00
[switch]$Force
2024-05-17 19:25:09 +02:00
)
2024-05-17 19:47:34 +02:00
# Enable TLSv1.2 for compatibility with older windows versions
2024-04-01 15:15:02 +02:00
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
2024-05-17 19:47:34 +02:00
$path = "$env:LOCALAPPDATA\DSR"
$update = Test-Path -Path $path\*
2024-04-01 15:15:02 +02:00
# Download
$releases = "https://git.mylloon.fr/api/v1/repos/Anri/dsr/releases/latest"
$link = (Invoke-WebRequest $releases | ConvertFrom-Json)[0].assets.browser_download_url
$archive = "$env:TEMP\dsr.zip"
Invoke-WebRequest -Uri $link -OutFile $archive
2024-05-17 19:47:34 +02:00
Remove-Item "$path" -Recurse -ErrorAction SilentlyContinue
2024-04-01 15:15:02 +02:00
# Installation
2024-05-17 19:47:34 +02:00
Expand-Archive -Path $archive -DestinationPath "$path" -Force
Move-Item -Path "$path\dsr-win32-x64\*" -Destination "$path" -Force
Remove-Item "$path\dsr-win32-x64"
2024-04-01 15:15:02 +02:00
2024-04-01 15:27:12 +02:00
# Ask user to add a shortcut to the desktop
2024-05-17 19:47:34 +02:00
if (-not $update -Or $Force) {
2024-05-17 19:36:08 +02:00
# Add shortcut
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:APPDATA\Microsoft\Windows\Start Menu\Programs\DSR.lnk")
2024-05-17 19:47:34 +02:00
$Shortcut.TargetPath = "$path\dsr.exe"
2024-05-17 19:36:08 +02:00
$Shortcut.Save()
# Add new app to registry
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\dsr" /f /v DisplayName /t REG_SZ /d "DSR"
2024-05-17 19:47:34 +02:00
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\dsr" /f /v InstallLocation /t REG_SZ /d "$path"
2024-05-17 19:36:08 +02:00
2024-05-17 19:25:09 +02:00
if ($Host.UI.PromptForChoice(
"***********************",
"Add a desktop shortcut?",
@(
2024-04-01 15:27:12 +02:00
[System.Management.Automation.Host.ChoiceDescription]::new("&Yes", "Add a shortcut to your desktop.")
[System.Management.Automation.Host.ChoiceDescription]::new("&No", "Skip the shortcut creation.")
2024-05-17 19:25:09 +02:00
), 1) -eq 0) {
$WshShell = New-Object -comObject WScript.Shell
$Desktop = [Environment]::GetFolderPath("Desktop")
$Shortcut = $WshShell.CreateShortcut("$Desktop\DSR.lnk")
2024-05-17 19:47:34 +02:00
$Shortcut.TargetPath = "$path\dsr.exe"
2024-05-17 19:25:09 +02:00
$Shortcut.Save()
}
2024-04-01 15:27:12 +02:00
}