@echo off
rem RentGPUPower - the one-click installer for Windows (served by server.js
rem as /download/install-windows, stamped with the marketplace's address).
rem
rem For whoever has never opened PowerShell: a double-click runs exactly the
rem one line /download shows - irm https://rentgpupower.com/install.ps1 ^| iex - in
rem this window, which shows every step. This file installs nothing itself.
title RentGPUPower - installing

rem Windows PowerShell where Windows keeps it: a PATH that has lost it, or a
rem "powershell" lying in the Downloads folder, must not decide what runs.
rem GPURENT_POWERSHELL: a test's stand-in (scripts/e2e-install.mjs).
set "GPURENT_PS=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"
if not exist "%GPURENT_PS%" set "GPURENT_PS=powershell.exe"
if defined GPURENT_POWERSHELL set "GPURENT_PS=%GPURENT_POWERSHELL%"

rem TLS 1.2 switched on first: an older Windows 10 asks with TLS 1.0, which
rem the server refuses, and the install died before its first line.
rem A failure install.ps1 explains itself ends it with "return", which
rem PowerShell counts as a success: so the install counts as done only when
rem its last step set $global:GpurentInstalled. Without that, the window
rem closed by itself in a minute, over the message that said what went wrong.
call "%GPURENT_PS%" -NoProfile -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor 3072; irm 'https://rentgpupower.com/install.ps1' | iex; if (-not $global:GpurentInstalled) { exit 1 }"
if errorlevel 1 goto failed

echo.
echo   This window closes by itself in a minute - or close it now.
timeout /t 60 >nul 2>nul
exit /b 0

:failed
echo.
echo   The install did not finish - the message above says why.
echo   Open this file again to try once more, or paste the line shown on
echo   https://rentgpupower.com/download into PowerShell.
echo.
pause
exit /b 1
