# Downloads the WebView2 Runtime installers into windows\webview2_runtime\. # # build.spec bundles: # - MicrosoftEdgeWebview2Setup.exe (~1.7 MB) always # - MicrosoftEdgeWebView2RuntimeInstallerX64.exe (~203 MB) only if present # # The bootstrapper is the small online installer (it downloads the Runtime # from Microsoft). Run this script with -Offline to also fetch the standalone # installer for machines that have no internet access — note that it makes the # built .exe about 200 MB larger. # # Usage: # .\download_runtime_installers.ps1 # .\download_runtime_installers.ps1 -Offline [CmdletBinding()] param( [switch]$Offline ) $ErrorActionPreference = 'Stop' $dest = Join-Path $PSScriptRoot 'webview2_runtime' if (-not (Test-Path $dest)) { New-Item -ItemType Directory -Force -Path $dest | Out-Null } $bootstrapperUrl = 'https://go.microsoft.com/fwlink/p/?LinkId=2124703' $standaloneUrl = 'https://go.microsoft.com/fwlink/?linkid=2124701' # x64 function Get-Installer { param([string]$Url, [string]$FileName, [string]$Label) $target = Join-Path $dest $FileName Write-Host "[INFO] Downloading $Label ..." -ForegroundColor Cyan Invoke-WebRequest -Uri $Url -OutFile $target -UseBasicParsing -MaximumRedirection 10 $file = Get-Item -LiteralPath $target $sig = Get-AuthenticodeSignature -LiteralPath $target $sizeMb = [math]::Round($file.Length / 1MB, 1) Write-Host (" {0} {1} MB" -f $file.Name, $sizeMb) if ($sig.Status -eq 'Valid' -and $sig.SignerCertificate.Subject -like '*Microsoft*') { Write-Host " signature: Valid (Microsoft)" -ForegroundColor Green } else { Write-Warning " signature: $($sig.Status) — verify this download!" } } Get-Installer -Url $bootstrapperUrl -FileName 'MicrosoftEdgeWebview2Setup.exe' -Label 'Runtime bootstrapper (online)' if ($Offline) { Get-Installer -Url $standaloneUrl -FileName 'MicrosoftEdgeWebView2RuntimeInstallerX64.exe' -Label 'Runtime standalone installer (offline, x64)' Write-Host '' Write-Host '[WARN] The standalone installer adds ~203 MB to the built .exe.' -ForegroundColor Yellow } else { Write-Host '' Write-Host '[INFO] Offline installer skipped. Re-run with -Offline to include it.' -ForegroundColor DarkGray } Write-Host '' Write-Host "[OK] Installers are in $dest" -ForegroundColor Green Write-Host ' Next: rebuild with venv\Scripts\python.exe -m PyInstaller build.spec --clean --noconfirm'