# Browsentic for Windows, installed in one line: # # irm https://browsentic.com/install.ps1 | iex # # Downloads the release installer for this computer's architecture, installs it for this user # only, and opens the app. The app does the rest from a window. Nothing here needs an # administrator, and a file PowerShell downloads carries no mark for SmartScreen to warn about. # # $env:BROWSENTIC_VERSION = '0.8.0' install that release instead of the latest # $env:BROWSENTIC_NO_OPEN = '1' install without opening the app & { $ErrorActionPreference = 'Stop' # Windows PowerShell redraws its progress bar for every chunk, which makes a download crawl. $ProgressPreference = 'SilentlyContinue' $repo = 'imshaikot/browsentic' function Say([string] $text) { Write-Host " $text" } try { if ([Environment]::OSVersion.Version.Major -lt 10) { throw 'the app needs Windows 10 or 11. Use: npx browsentic setup' } # The computer's own architecture, as Windows records it, rather than this PowerShell's: Windows # PowerShell 5.1 can leave RuntimeInformation.OSArchitecture empty, and an x64 PowerShell on an # ARM computer is emulated and calls itself AMD64. $native = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -ErrorAction SilentlyContinue).PROCESSOR_ARCHITECTURE if (-not $native) { $native = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE } } $arch = switch ($native) { 'ARM64' { 'arm64' } 'AMD64' { 'x64' } default { $what = if ($native) { "$native computers" } else { 'this computer' } throw "there is no Windows app for $what yet. Use: npx browsentic setup" } } $version = $env:BROWSENTIC_VERSION if (-not $version) { try { $version = (Invoke-RestMethod "https://api.github.com/repos/$repo/releases/latest" -UseBasicParsing).tag_name -replace '^v', '' } catch { throw 'could not reach github.com to find the latest release. Check the connection and run this again.' } } if ($version -notmatch '^\d+\.\d+\.\d+') { throw "could not work out the latest version (got `"$version`"). Set `$env:BROWSENTIC_VERSION = 'x.y.z' and run this again." } $name = "Browsentic-$version-$arch-setup.exe" $url = if ($env:BROWSENTIC_DOWNLOAD_BASE) { "$($env:BROWSENTIC_DOWNLOAD_BASE.TrimEnd('/'))/$name" } else { "https://github.com/$repo/releases/download/v$version/$name" } $setup = Join-Path $env:TEMP $name Write-Host "`n Browsentic $version`n" Say 'Downloading' try { Invoke-WebRequest $url -OutFile $setup -UseBasicParsing } catch { throw "release v$version carries no Windows app for $arch yet. See https://github.com/$repo/releases" } $running = Get-Process Browsentic -ErrorAction SilentlyContinue if ($running) { Say 'Closing the running app' $running | Stop-Process -Force Start-Sleep -Seconds 1 } Say 'Installing for this user' $install = Start-Process $setup -ArgumentList '/S' -Wait -PassThru Remove-Item $setup -Force -ErrorAction SilentlyContinue if ($install.ExitCode -ne 0) { throw "the installer stopped with code $($install.ExitCode). Run this again, or download it from https://github.com/$repo/releases" } $uninstall = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Browsentic' $icon = (Get-ItemProperty $uninstall -ErrorAction SilentlyContinue).DisplayIcon $app = if ($icon) { $icon.Trim('"') -replace ',\d+$', '' } else { Join-Path $env:LOCALAPPDATA 'Browsentic\Browsentic.exe' } if ($env:BROWSENTIC_NO_OPEN) { Write-Host "`n Done. Open Browsentic from the Start menu, and press `"Set up everything`".`n" } else { Write-Host "`n Done. Opening Browsentic: press `"Set up everything`" and it installs the rest.`n" Start-Process $app } } catch { Write-Host "`n browsentic: $($_.Exception.Message)`n" -ForegroundColor Red } }