# Pabimatic v1-0 - lanzador web para Windows PowerShell 5.1. # Descarga el paquete, verifica SHA-256 y abre la interfaz; no aplica limpieza. & { Set-StrictMode -Version 2.0 $ErrorActionPreference = 'Stop' if ($env:OS -ne 'Windows_NT') { throw 'Pabimatic requiere Windows.' } if ($PSVersionTable.PSVersion -lt [version]'5.1') { throw 'Se requiere PowerShell 5.1 o posterior para descargar el paquete.' } $expectedHash = '204d4189b695a0a35559c1c3294397670669e233a73e151ec4b7662c4174676f' $packageUrl = 'https://get.unionobreroscoatza.com.mx/Pabimatic-v1-0.zip?sha256=' + $expectedHash $work = Join-Path $env:LOCALAPPDATA ('Pabimatic\Descargas\' + [guid]::NewGuid().ToString('N')) $oldTls = [Net.ServicePointManager]::SecurityProtocol try { Write-Host '' Write-Host 'Pabimatic' -ForegroundColor Cyan Write-Host 'Para Pc | elige, revisa y aplica | v1-0' Write-Host '' Write-Host '[1/4] Preparando la descarga...' New-Item -ItemType Directory -Path $work -Force | Out-Null $zipPath = Join-Path $work 'Pabimatic-v1-0.zip' [Net.ServicePointManager]::SecurityProtocol = $oldTls -bor [Net.SecurityProtocolType]::Tls12 Invoke-WebRequest -Uri $packageUrl -UseBasicParsing -OutFile $zipPath -TimeoutSec 180 Write-Host '[2/4] Verificando la integridad del paquete...' $actualHash = (Get-FileHash -LiteralPath $zipPath -Algorithm SHA256).Hash if ($actualHash -ne $expectedHash) { throw 'El archivo descargado no coincide con el paquete publicado. No se ejecutara.' } Add-Type -AssemblyName System.IO.Compression.FileSystem $expectedEntries = @( 'Pabimatic/ABRIR.cmd', 'Pabimatic/Base-Windows.ps1', 'Pabimatic/Catalogo.ps1', 'Pabimatic/LEEME.txt', 'Pabimatic/Motor.ps1' ) $archive = [IO.Compression.ZipFile]::OpenRead($zipPath) try { if ($archive.Entries.Count -ne $expectedEntries.Count) { throw 'Estructura inesperada del paquete.' } $seen = New-Object 'System.Collections.Generic.HashSet[string]' foreach ($entry in $archive.Entries) { if ($expectedEntries -cnotcontains $entry.FullName -or -not $seen.Add($entry.FullName)) { throw 'El paquete contiene una ruta inesperada o duplicada.' } } } finally { $archive.Dispose() } Write-Host '[3/4] Extrayendo Pabimatic...' $destination = Join-Path $work 'Programa' Expand-Archive -LiteralPath $zipPath -DestinationPath $destination -ErrorAction Stop $main = Join-Path $destination 'Pabimatic\Base-Windows.ps1' if (-not (Test-Path -LiteralPath $main -PathType Leaf)) { throw 'No se encontro el programa principal.' } $psExe = Join-Path $env:SystemRoot 'System32\WindowsPowerShell\v1.0\powershell.exe' if ([Environment]::Is64BitOperatingSystem -and -not [Environment]::Is64BitProcess) { $psExe = Join-Path $env:SystemRoot 'Sysnative\WindowsPowerShell\v1.0\powershell.exe' } if (-not (Test-Path -LiteralPath $psExe)) { throw 'No se encontro Windows PowerShell.' } Write-Host '[4/4] Abriendo la ventana...' $process = Start-Process -FilePath $psExe -ArgumentList @('-NoLogo','-NoProfile','-STA','-ExecutionPolicy','Bypass','-File',('"' + $main + '"')) -PassThru Write-Host 'Pabimatic se esta iniciando. Comienza con Revisar cambios.' -ForegroundColor Green Write-Host ('Archivos descargados en: ' + $work) $process.Dispose() } catch { Write-Host ('No se pudo iniciar Pabimatic: ' + $_.Exception.Message) -ForegroundColor Red throw } finally { [Net.ServicePointManager]::SecurityProtocol = $oldTls } }