@echo off
:: Install GACars Certificate (Run as Administrator)
:: This adds the public certificate to Windows Trusted Root store
:: so Windows recognizes the GACars app signature.

net session >nul 2>&1
if %errorlevel% neq 0 (
    echo.
    echo [ERROR] This script must be run as Administrator!
    echo Right-click this file and select "Run as administrator"
    echo.
    pause
    exit /b 1
)

echo.
echo ========================================
echo   GACars - Installing Certificate
echo ========================================
echo.

set "SCRIPT_DIR=%~dp0"
set "CER_PATH=%SCRIPT_DIR%gacars-signing.cer"

if not exist "%CER_PATH%" (
    echo [ERROR] Certificate file not found: gacars-signing.cer
    echo Make sure this .bat file is in the same folder as the certificate.
    pause
    exit /b 1
)

echo [1/3] Importing certificate to Trusted Root store...
certutil -addstore -f Root "%CER_PATH%" >nul 2>&1
if %errorlevel% neq 0 (
    echo [ERROR] Failed to import certificate.
    pause
    exit /b 1
)
echo       Done.

echo [2/3] Verifying installation...
certutil -verifystore Root "AStech" >nul 2>&1
if %errorlevel% equ 0 (
    echo       Verified: AStech certificate found in Trusted Root store.
) else (
    echo       Warning: Could not verify, but import may have succeeded.
)

echo [3/3] Done.
echo.
echo ========================================
echo   Certificate installed successfully!
echo   You can now run GACars without
echo   SmartScreen warnings.
echo ========================================
echo.
pause
