@echo off setlocal enabledelayedexpansion pushd %~dp0 set "ROOT=%CD%" call "%ROOT%\build.bat" if %ERRORLEVEL% neq 0 ( echo build failed popd exit /b 1 ) rem Resolve the real Documents folder (respects OneDrive / folder redirection). for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "[Environment]::GetFolderPath('MyDocuments')"`) do set "DOCS=%%i" if not defined DOCS set "DOCS=%USERPROFILE%\Documents" set "INSTALL_ROOT=%DOCS%\KiCad\10.0\plugins" set "INSTALL_DIR=%INSTALL_ROOT%\com.jesshunter.layers" if not exist "%INSTALL_ROOT%" mkdir "%INSTALL_ROOT%" >nul 2>&1 rem Preserve user state (state/, cache/, logs/, settings.json) across reinstall. if exist "%INSTALL_DIR%\bin" rmdir /s /q "%INSTALL_DIR%\bin" if exist "%INSTALL_DIR%\resources" rmdir /s /q "%INSTALL_DIR%\resources" if exist "%INSTALL_DIR%\plugin.json" del /q "%INSTALL_DIR%\plugin.json" if exist "%INSTALL_DIR%\LICENCE" del /q "%INSTALL_DIR%\LICENCE" set "STAGE=%ROOT%\build\bin\com.jesshunter.layers" xcopy /e /i /y /q "%STAGE%" "%INSTALL_DIR%" >nul echo. echo installed: %INSTALL_DIR% echo. popd endlocal