@echo off
:: 设置控制台为简体中文编码
chcp 936 >nul
setlocal enabledelayedexpansion

echo ======================================================
echo           Leishen Tools - One-Click Installer
echo ======================================================
echo.

set "TARGET_DIR=%AppData%\Autodesk\ApplicationPlugins\LeishenToolbox.bundle"
set "SOURCE_DIR=%~dp0LeishenToolbox.bundle"

if not exist "%SOURCE_DIR%" (
    echo [Error] Cannot find LeishenToolbox.bundle folder!
    pause
    exit /b
)

if exist "%TARGET_DIR%" (
    echo [Status] Updating existing installation...
) else (
    echo [Status] Creating installation directory...
    mkdir "%AppData%\Autodesk\ApplicationPlugins" 2>nul
)

echo [Status] Copying files, please wait...
xcopy "%SOURCE_DIR%" "%TARGET_DIR%" /I /E /Y /Q

if %ERRORLEVEL% EQU 0 (
    echo.
    echo ======================================================
    echo [Success] Installation Completed!
    echo [Notice] Please restart AutoCAD to use the plugin.
    echo ======================================================
) else (
    echo.
    echo [Warning] Some files could not be copied. Close AutoCAD and try again.
)

echo.
pause