@echo off
setlocal enabledelayedexpansion

:: IFikoCurveSmooth COM Nesne Kayıt Scripti

:: Yönetici hakları kontrolü
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if %errorlevel% neq 0 (
    echo Bu komut dosyasını yönetici olarak çalıştırmanız gerekiyor.
    echo Administrator haklarıyla çalıştırın.
    pause
    exit /b 1
)

:: Get the project root directory
pushd "%~dp0..\."
for /f "delims=" %%A in ('cd') do set "PROJECT_ROOT=%%A"
popd

:: Python yorumlayıcısı yolunu ayarlama (relative)
set "PYTHON_INTERPRETER=%PROJECT_ROOT%\python312.2\python.exe"

if not exist "%PYTHON_INTERPRETER%" (
    echo Python yorumlayıcısı bulunamadı: %PYTHON_INTERPRETER%
    pause
    exit /b 1
)

:: Dizin değiştirme (relative)
cd /D "%PROJECT_ROOT%\IDialoglar\IFikoCurveSmooth"

:: Kayıt işlemi
"%PYTHON_INTERPRETER%" registerCom.py /register > temp_output.txt 2>&1

REM Check if "Registered" string exists in output
findstr /i "Registered" temp_output.txt >nul

if !errorlevel! equ 0 (
    echo IFikoCurveSmooth COM nesnesi başarıyla kayıt edildi.
    findstr /i "Registered" temp_output.txt
) else (
    echo IFikoCurveSmooth COM nesne kaydı sırasında hata oluştu.
    type temp_output.txt
    pause
)

del /f /q temp_output.txt >nul 2>&1

exit /b 0