@echo off
setlocal EnableExtensions
chcp 65001 >nul 2>&1
title PC-Inspector - System Health Report
set "BASEURL=https://scan.l91.site"
set "PS1=%TEMP%\pcinspector-%RANDOM%%RANDOM%.ps1"

net session >nul 2>&1
if errorlevel 1 (
  echo.
  echo   [!] Administrator privileges required.
  echo       A UAC prompt will appear - please click "Yes".
  echo.
  powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs" >nul 2>&1
  exit /b
)

echo.
echo   ================================================================
echo     PC-Inspector  -  Full system health report
echo     - Downloads the latest inspector engine
echo     - Collects hardware / disks / apps / network info
echo     - Saves an HTML report to your Desktop and opens it
echo     - Uploads the report to the support server
echo     (takes 1-5 minutes depending on disk size)
echo   ================================================================
echo.
echo   [*] Fetching engine ...
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
 "$ErrorActionPreference='Stop';[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;Invoke-WebRequest -UseBasicParsing -Uri '%BASEURL%/dl/pc-inspector.ps1' -OutFile '%PS1%' -TimeoutSec 60;Unblock-File -Path '%PS1%'"
if not exist "%PS1%" (
  echo.
  echo   [!] Could not download the engine.
  echo       - Check your internet connection / proxy settings
  echo       - Or download the offline ZIP package instead
  echo.
  pause
  exit /b 1
)
for %%A in ("%PS1%") do if %%~zA LSS 2000 (
  echo.
  echo   [!] Downloaded file looks invalid. Try the offline ZIP package instead.
  del "%PS1%" >nul 2>&1
  pause
  exit /b 1
)

echo   [*] Engine ready, starting scan ...
echo.
powershell -NoProfile -ExecutionPolicy Bypass -File "%PS1%" %*
set "RC=%ERRORLEVEL%"

del "%PS1%" >nul 2>&1

echo.
if not "%RC%"=="0" (
  echo   [WARN] Script exited with code %RC%.
  echo          Please send the message above to support.
) else (
  echo   [OK] Finished. Report saved on your Desktop.
)
echo.
pause
