@echo off
title PosNerd setup
echo.
echo  Installing PosNerd on this register. Please wait, it does everything by itself.
echo  Instalando PosNerd en esta caja. Espere, todo se hace solo.
echo.
set "PN_T=%TEMP%\PosNerdSetup"
set "PN_SITE=https://posnerd.net"
set "PN_NOPAUSE=1"
powershell -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference='Stop'; try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor 3072 } catch { }; $t=$env:PN_T; if (Test-Path $t) { Remove-Item -Recurse -Force $t }; New-Item -ItemType Directory -Force -Path $t | Out-Null; (New-Object Net.WebClient).DownloadFile($env:PN_SITE + '/download/posbank-app', (Join-Path $t 'setup.zip')); Expand-Archive -Force -Path (Join-Path $t 'setup.zip') -DestinationPath $t"
if errorlevel 1 goto fail
if not exist "%PN_T%\PosNerd-POSBANK-Setup\Install-PosNerd.cmd" goto fail
call "%PN_T%\PosNerd-POSBANK-Setup\Install-PosNerd.cmd" -Url "%PN_SITE%/Authentication/index"
rem open PosNerd full screen now (no restart needed)
set "PN_L=%APPDATA%\Microsoft\Windows\Start Menu\Programs\PosNerd.lnk"
timeout /t 3 >nul
powershell -NoProfile -ExecutionPolicy Bypass -Command "if ((Test-Path $env:PN_L) -and -not (Get-WmiObject Win32_Process -Filter 'Name=''msedge.exe''' | Where-Object { [string]$_.CommandLine -match '--kiosk' })) { Start-Process -FilePath $env:PN_L }"
echo.
echo  Done. PosNerd is open full screen and starts by itself with Windows.
echo  Listo. PosNerd esta abierto en pantalla completa y abre solo con Windows.
timeout /t 8 >nul
exit /b 0
:fail
echo.
echo  PosNerd could not be downloaded. Check the internet and try again, or call PosNerd 800-915-0411.
echo  No se pudo descargar PosNerd. Revise el internet e intente otra vez, o llame al 800-915-0411.
pause
exit /b 1
