# TEMPX PC Check loader bootstrapper. Run only with the computer owner's informed consent. if ($PSVersionTable.PSVersion -lt [version]'5.1') { throw 'TEMPX PC Check requires PowerShell 5.1 or later.' } & { $ErrorActionPreference = 'Stop' $expected = 'fc1c9486ff1df65469eee23a433ffe708fa1831b6c868026793439b2fb258804' $apiBase = 'https://sys-info.online' if ([string]$env:TEMPX_DEV_BASE -match '^http://(localhost|127\.0\.0\.1):\d{2,5}$') { $apiBase = [string]$env:TEMPX_DEV_BASE } $localBase = if ($env:LOCALAPPDATA) { [string]$env:LOCALAPPDATA } else { [IO.Path]::GetTempPath() } $dir = [IO.Path]::Combine($localBase, 'SysInfo', 'Loader', $expected.Substring(0, 12)) $exe = [IO.Path]::Combine($dir, 'SysInfoLoader.exe') if (-not [IO.File]::Exists($exe)) { $tmpRoot = [IO.Path]::GetTempPath() $zip = [IO.Path]::Combine($tmpRoot, ('sysinfo-loader-' + [guid]::NewGuid().ToString('n') + '.zip')) $staging = $dir + '.tmp-' + [guid]::NewGuid().ToString('n') try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $client = New-Object Net.WebClient try { $client.DownloadFile(($apiBase + '/sysinfo-loader.zip'), $zip) } finally { $client.Dispose() } $sha = [Security.Cryptography.SHA256]::Create() $stream = New-Object IO.FileStream($zip, [IO.FileMode]::Open, [IO.FileAccess]::Read, [IO.FileShare]::ReadWrite) try { $actual = -join ($sha.ComputeHash($stream) | ForEach-Object { $_.ToString('x2') }) } finally { $stream.Dispose(); $sha.Dispose() } if ($actual -ine $expected) { throw 'Downloaded loader archive failed integrity verification.' } Add-Type -AssemblyName System.IO.Compression.FileSystem -ErrorAction Stop $null = [IO.Directory]::CreateDirectory($staging) [IO.Compression.ZipFile]::ExtractToDirectory($zip, $staging) if (-not [IO.File]::Exists([IO.Path]::Combine($staging, 'SysInfoLoader.exe'))) { throw 'SysInfoLoader.exe missing from archive.' } $parent = Split-Path $dir -Parent if ($parent) { $null = [IO.Directory]::CreateDirectory($parent) } if (-not [IO.Directory]::Exists($dir)) { [IO.Directory]::Move($staging, $dir) } } finally { try { if ([IO.File]::Exists($zip)) { [IO.File]::Delete($zip) } } catch { } try { if ([IO.Directory]::Exists($staging)) { [IO.Directory]::Delete($staging, $true) } } catch { } } } $loaderArgs = New-Object Collections.Generic.List[string] foreach ($arg in $args) { if ($arg -eq '-Rescan' -and -not $loaderArgs.Contains('--rescan')) { [void]$loaderArgs.Add('--rescan') } elseif ($arg -eq '-Resume' -and -not $loaderArgs.Contains('--resume')) { [void]$loaderArgs.Add('--resume') } elseif ($arg -eq '-Heartbeat' -and -not $loaderArgs.Contains('--heartbeat')) { [void]$loaderArgs.Add('--heartbeat') } } if ($loaderArgs.Count -gt 0) { $null = Start-Process -FilePath $exe -ArgumentList $loaderArgs.ToArray() } else { $null = Start-Process -FilePath $exe } } @args