automatic update

This commit is contained in:
Mylloon 2024-05-17 19:47:34 +02:00
parent e108ae3097
commit f9d812f9b2
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 13 additions and 18 deletions

View file

@ -18,14 +18,6 @@ Tool for sharing video to Discord.
> - If you have Discord Nitro: add `/nitro` flag when running DSR.
> - If you have an NVidia GPU with NVenc: add `/nvenc` flag when running DSR.
## Update
Via PowerShell:
```powershell
iex "& { $(irm 'https://git.mylloon.fr/Anri/dsr/raw/branch/main/install.ps1') } -update"
```
## More info
- [x] KISS interface

View file

@ -1,33 +1,36 @@
param (
[switch]$update
[switch]$Force
)
# Enable TLSv1.2 for compatibility with older clients
# Enable TLSv1.2 for compatibility with older windows versions
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
$path = "$env:LOCALAPPDATA\DSR"
$update = Test-Path -Path $path\*
# 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
Remove-Item "$env:LOCALAPPDATA\DSR" -Recurse -ErrorAction SilentlyContinue
Remove-Item "$path" -Recurse -ErrorAction SilentlyContinue
# Installation
Expand-Archive -Path $archive -DestinationPath "$env:LOCALAPPDATA\DSR" -Force
Move-Item -Path "$env:LOCALAPPDATA\DSR\dsr-win32-x64\*" -Destination "$env:LOCALAPPDATA\DSR" -Force
Remove-Item "$env:LOCALAPPDATA\DSR\dsr-win32-x64"
Expand-Archive -Path $archive -DestinationPath "$path" -Force
Move-Item -Path "$path\dsr-win32-x64\*" -Destination "$path" -Force
Remove-Item "$path\dsr-win32-x64"
# Ask user to add a shortcut to the desktop
if (-not $update) {
if (-not $update -Or $Force) {
# Add shortcut
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:APPDATA\Microsoft\Windows\Start Menu\Programs\DSR.lnk")
$Shortcut.TargetPath = "$env:LOCALAPPDATA\DSR\dsr.exe"
$Shortcut.TargetPath = "$path\dsr.exe"
$Shortcut.Save()
# Add new app to registry
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\dsr" /f /v DisplayName /t REG_SZ /d "DSR"
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\dsr" /f /v InstallLocation /t REG_SZ /d "$env:LOCALAPPDATA\DSR"
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\dsr" /f /v InstallLocation /t REG_SZ /d "$path"
if ($Host.UI.PromptForChoice(
"***********************",
@ -39,7 +42,7 @@ if (-not $update) {
$WshShell = New-Object -comObject WScript.Shell
$Desktop = [Environment]::GetFolderPath("Desktop")
$Shortcut = $WshShell.CreateShortcut("$Desktop\DSR.lnk")
$Shortcut.TargetPath = "$env:LOCALAPPDATA\DSR\dsr.exe"
$Shortcut.TargetPath = "$path\dsr.exe"
$Shortcut.Save()
}
}