# Pantheon Desk for Windows. Paste into PowerShell: # $env:PDESK_INVITE='YOUR INVITE LINK'; irm https://pantheon-desk.vercel.app/install.ps1 | iex # With an invite it first installs Pantheon and joins you to the team (it asks for your email and a code). # Then it installs Pantheon Desk, adds it to the Start menu, the desktop and startup, and opens it. $ErrorActionPreference = "Stop" # Windows PowerShell 5.1 on an older setup may not use TLS 1.2 for downloads by itself; every host here needs it. try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 } catch { } $ProgressPreference = "SilentlyContinue" $URL = "https://pantheon-desk.vercel.app" # Everything this window shows also goes to a log, so a failed setup can be sent to whoever invited you. $log = Join-Path $env:TEMP "PantheonDesk-setup.log" try { Start-Transcript -Path $log -Force | Out-Null } catch { } trap { Write-Host "`nSetup stopped: $($_.Exception.Message)" -ForegroundColor Red Write-Host "Send this file to whoever invited you: $log" -ForegroundColor Yellow try { Stop-Transcript | Out-Null } catch { } break } $invite = $env:PDESK_INVITE function Say($t) { Write-Host "`n$t" -ForegroundColor Cyan } $pantheonCmd = Join-Path $env:USERPROFILE ".pantheon\bin\pantheon.cmd" $hasPantheon = (Test-Path $pantheonCmd) -or (Get-Command pantheon -ErrorAction SilentlyContinue) if ($invite -and -not $hasPantheon) { Say "Step 1 of 2: installing Pantheon and joining your team" Set-Item Env:PANTHEON_ARGS "join $invite" $joined = $true try { Invoke-RestMethod https://relay.joinpantheon.network/install.ps1 | Invoke-Expression } catch { $joined = $false } } elseif (-not $invite -and -not $hasPantheon) { # No invite: install Pantheon only. Signing in and joining happen in the app. Say "Step 1 of 2: installing Pantheon" Set-Item Env:PANTHEON_ARGS "" Invoke-RestMethod https://relay.joinpantheon.network/install.ps1 | Invoke-Expression } elseif ($invite) { Say "Step 1 of 2: joining your team" $p = if (Test-Path $pantheonCmd) { $pantheonCmd } else { (Get-Command pantheon).Source } & $p join $invite $joined = ($LASTEXITCODE -eq 0) } # Node: Pantheon's own, or one already on this computer. $node = Join-Path $env:USERPROFILE ".pantheon\runtime\node\node.exe" if (-not (Test-Path $node)) { $c = Get-Command node -ErrorAction SilentlyContinue; if ($c) { $node = $c.Source } else { $node = $null } } if (-not $node) { Write-Host "Pantheon isn't installed yet. Run this again with the invite link your teammate sent (see the first line of the instructions)." -ForegroundColor Yellow; return } $major = [int]((& $node -p "process.versions.node.split('.')[0]").Trim()) if ($major -lt 20) { Write-Host "This computer's Node is too old (needs 20 or newer). Run this again with your invite link: it installs Pantheon with its own Node." -ForegroundColor Yellow; return } Say "Step 2 of 2: installing Pantheon Desk" $home2 = Join-Path $env:LOCALAPPDATA "PantheonDesk" New-Item -ItemType Directory -Force -Path $home2 | Out-Null $tmp = Join-Path $env:TEMP ("pdesk-" + [guid]::NewGuid().ToString("N")) New-Item -ItemType Directory -Force -Path $tmp | Out-Null Invoke-WebRequest "$URL/updater.mjs" -OutFile (Join-Path $tmp "updater.mjs") -UseBasicParsing & $node (Join-Path $tmp "updater.mjs") install if ($LASTEXITCODE -ne 0 -or -not (Test-Path (Join-Path $home2 "current.txt"))) { throw "Couldn't download Pantheon Desk. Check the internet connection and run this again." } Remove-Item -Recurse -Force $tmp # A fixed launcher that always starts the current version (updates swap current.txt). @' import { readFileSync } from "node:fs"; import { join, dirname } from "node:path"; import { pathToFileURL, fileURLToPath } from "node:url"; const home = dirname(fileURLToPath(import.meta.url)); const v = readFileSync(join(home, "current.txt"), "utf8").trim(); const desk = join(home, "versions", v, "desk.mjs"); process.argv[1] = desk; await import(pathToFileURL(desk).href); '@ | ForEach-Object { [IO.File]::WriteAllText((Join-Path $home2 "launch.mjs"), $_, (New-Object System.Text.UTF8Encoding($false))) } $edge = @("${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe", "$env:ProgramFiles\Microsoft\Edge\Application\msedge.exe") | Where-Object { Test-Path $_ } | Select-Object -First 1 $shell = New-Object -ComObject WScript.Shell $dirs = @([Environment]::GetFolderPath("Programs"), [Environment]::GetFolderPath("Desktop"), [Environment]::GetFolderPath("Startup")) foreach ($d in $dirs) { $lnk = $shell.CreateShortcut((Join-Path $d "Pantheon Desk.lnk")) $lnk.TargetPath = $node $lnk.Arguments = "`"$home2\launch.mjs`"" if ($d -eq [Environment]::GetFolderPath("Startup")) { $lnk.Arguments += " --no-window" } $lnk.WorkingDirectory = $home2 $lnk.WindowStyle = 7 $lnk.Description = "Pantheon Desk" if ($edge) { $lnk.IconLocation = "$edge,0" } $lnk.Save() } & $node (Join-Path $home2 "launch.mjs") # Wait for Desk to answer, so a server that can't start says so here instead of failing silently. $inst = Join-Path $env:USERPROFILE ".pantheon-desk\instance.json" $up = $false for ($i = 0; $i -lt 40 -and -not $up; $i++) { Start-Sleep -Milliseconds 500 # A ping that needs no key (8 Nov, R4-SEC01): instance.json holds only the port and the process now. try { $j = Get-Content -Raw $inst | ConvertFrom-Json; $r = Invoke-WebRequest "http://127.0.0.1:$($j.port)/api/ping" -UseBasicParsing -TimeoutSec 3; $up = ($r.StatusCode -eq 200) } catch { } } if (-not $up) { $srvLog = Join-Path $env:USERPROFILE ".pantheon-desk\server.log" if (Test-Path $srvLog) { Write-Host "`nLast lines from Desk:"; Get-Content $srvLog -Tail 25 } throw "Pantheon Desk was installed but didn't start." } Say "Done. Pantheon Desk is opening. It's in the Start menu and on your desktop, and starts when you log in." if ($joined -eq $false) { Write-Host "Joining the team didn't finish (the invite may be used or expired). Ask for a new invite, then in the app click + Add next to Teams and paste it." -ForegroundColor Yellow } Write-Host "It updates itself: when you're told there's a new version, press F5 in its window." try { Stop-Transcript | Out-Null } catch { }