# cgshare one-line installer for Windows # irm https://tokensale.pc.am/install.ps1 | iex # # Downloads the official MSI from tokensale.pc.am, verifies its SHA-256, # installs it (per-user, no admin rights needed) and launches cgshare. # Nothing else is downloaded or executed. $ErrorActionPreference = 'Stop' $BaseUrl = 'https://tokensale.pc.am/download' $MsiName = 'cgshare-Setup-1.2.3.msi' $Version = '1.2.3' $Installer = Join-Path $env:LOCALAPPDATA 'Programs\cgshare\cgshare.exe' Write-Host 'cgshare installer' -ForegroundColor Cyan if (-not [Environment]::Is64BitOperatingSystem) { throw 'cgshare needs 64-bit Windows 10 or 11.' } # Already on this version? Just launch it. $installed = Get-ChildItem 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' ` -ErrorAction SilentlyContinue | Where-Object { $_.GetValue('DisplayName') -eq 'cgshare' } | ForEach-Object { $_.GetValue('DisplayVersion') } | Where-Object { $_ -eq $Version } if ((Test-Path $Installer) -and $installed) { Write-Host "cgshare $Version is already installed - launching it." -ForegroundColor Green Start-Process $Installer return } Get-Process cgshare -ErrorAction SilentlyContinue | Stop-Process -Force $tmp = Join-Path $env:TEMP $MsiName Write-Host "Downloading $MsiName ..." [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Invoke-WebRequest "$BaseUrl/$MsiName" -OutFile $tmp Write-Host 'Verifying download ...' $hashContent = (Invoke-WebRequest "$BaseUrl/$MsiName.sha256").Content if ($hashContent -is [byte[]]) { $hashContent = [Text.Encoding]::ASCII.GetString($hashContent) } $expected = $hashContent.Trim().Split(' ')[0].ToLower() $actual = (Get-FileHash $tmp -Algorithm SHA256).Hash.ToLower() if ($actual -ne $expected) { Remove-Item $tmp -Force -ErrorAction SilentlyContinue throw "SHA-256 mismatch (expected $expected, got $actual). Download discarded." } Write-Host 'Verified OK.' Write-Host 'Installing (a progress window may appear) ...' $proc = Start-Process msiexec.exe -ArgumentList @('/i', $tmp, '/passive', '/norestart') -Wait -PassThru if ($proc.ExitCode -notin 0, 1641, 3010) { throw "Installer failed with exit code $($proc.ExitCode). Try the manual download: https://tokensale.pc.am/#download" } Remove-Item $tmp -Force -ErrorAction SilentlyContinue if (Test-Path $Installer) { Write-Host 'Done - launching cgshare.' -ForegroundColor Green Write-Host 'Next: paste your connection bundle (cgshare1...) into the app and enrol this PC.' Start-Process $Installer } else { Write-Host 'Installed. Find "cgshare" in your Start Menu.' -ForegroundColor Green }