@echo off
title Maintenance PC - Technotrement
net session >nul 2>&1
if %errorlevel% neq 0 (
    powershell -Command "Start-Process cmd -ArgumentList '/c \"%~f0\"' -Verb RunAs"
    exit /b
)
set "PS1_URL=https://kb.technotrement.com/windows/maintenance-pc.ps1"
set "PS1_DEST=%TEMP%\maint_technotrement_%RANDOM%.ps1"
echo.
echo  =====================================================
echo   MAINTENANCE PC - Technotrement
echo   Machine : %COMPUTERNAME%
echo  =====================================================
echo.
echo  Telechargement du script...
curl -s -L -o "%PS1_DEST%" "%PS1_URL%"
if not exist "%PS1_DEST%" (
    echo  ERREUR : Impossible de telecharger le script.
    pause
    exit /b 1
)
echo  Lancement en cours...
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%PS1_DEST%" -BatPath "%~f0"
start /b "" cmd /c "ping 127.0.0.1 -n 3 >nul & del /f /q ""%~f0"""
