summaryrefslogtreecommitdiffstats
path: root/scripts/installers/windows.ps1.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/installers/windows.ps1.in')
-rw-r--r--scripts/installers/windows.ps1.in87
1 files changed, 0 insertions, 87 deletions
diff --git a/scripts/installers/windows.ps1.in b/scripts/installers/windows.ps1.in
deleted file mode 100644
index 4b8e61d..0000000
--- a/scripts/installers/windows.ps1.in
+++ /dev/null
@@ -1,87 +0,0 @@
1# Zagan-Bet desktop installer for Windows.
2#
3# Verifies the app against its published SHA-256, installs it for the current
4# user and adds a Start-menu shortcut. Put the downloaded app next to this
5# script, or run the script on its own and it will fetch the matching binary.
6#
7# Run it with:
8# powershell -ExecutionPolicy Bypass -File .\zagan-bet-gui-*-install.ps1
9# Add -NoPause to run it unattended.
10param([switch]$NoPause)
11
12$ErrorActionPreference = "Stop"
13
14$Version = "__VERSION__"
15$Binary = "__BINARY__"
16$Sha256 = "__SHA256__"
17$Url = "__URL__"
18
19function Finish([int]$Code) {
20 if (-not $NoPause) {
21 Read-Host "Press Enter to close" | Out-Null
22 }
23 exit $Code
24}
25
26function Stop-Install([string]$Message) {
27 Write-Host "install: $Message" -ForegroundColor Red
28 Finish 1
29}
30
31$here = Split-Path -Parent $MyInvocation.MyCommand.Path
32$candidates = @(
33 (Join-Path $here $Binary),
34 (Join-Path (Get-Location) $Binary),
35 (Join-Path $env:USERPROFILE "Downloads\$Binary")
36)
37$sourceFile = $null
38foreach ($candidate in $candidates) {
39 if (Test-Path -LiteralPath $candidate) {
40 $sourceFile = $candidate
41 break
42 }
43}
44
45$temporary = $null
46if (-not $sourceFile) {
47 $temporary = Join-Path ([System.IO.Path]::GetTempPath()) $Binary
48 Write-Host "Downloading $Binary..."
49 try {
50 Invoke-WebRequest -Uri $Url -OutFile $temporary -UseBasicParsing
51 } catch {
52 Stop-Install "download failed: $_"
53 }
54 $sourceFile = $temporary
55}
56
57try {
58 $actual = (Get-FileHash -LiteralPath $sourceFile -Algorithm SHA256).Hash.ToLowerInvariant()
59 if ($actual -ne $Sha256.ToLowerInvariant()) {
60 Stop-Install "checksum mismatch: expected $Sha256, got $actual"
61 }
62
63 $installDir = Join-Path $env:LOCALAPPDATA "Programs\Zagan-Bet"
64 New-Item -ItemType Directory -Force -Path $installDir | Out-Null
65 $target = Join-Path $installDir "zagan-bet-gui.exe"
66 Copy-Item -LiteralPath $sourceFile -Destination $target -Force
67
68 $startMenu = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs"
69 New-Item -ItemType Directory -Force -Path $startMenu | Out-Null
70 $shortcutPath = Join-Path $startMenu "Zagan-Bet.lnk"
71 $shell = New-Object -ComObject WScript.Shell
72 $shortcut = $shell.CreateShortcut($shortcutPath)
73 $shortcut.TargetPath = $target
74 $shortcut.WorkingDirectory = $installDir
75 $shortcut.IconLocation = "$target,0"
76 $shortcut.Description = "Slots, roulette, blackjack and crash"
77 $shortcut.Save()
78
79 Write-Host "Installed Zagan-Bet $Version to $target"
80 Write-Host "A Start-menu shortcut was created."
81} finally {
82 if ($temporary -and (Test-Path -LiteralPath $temporary)) {
83 Remove-Item -LiteralPath $temporary -Force
84 }
85}
86
87Finish 0