@echo off echo ==================================================== echo GeoMedical Complete Build Script echo Building both app.exe and updater.exe echo ==================================================== echo. REM Get current timestamp for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" set "HH=%dt:~8,2%" & set "NN=%dt:~10,2%" & set "SS=%dt:~12,2%" set "timestamp=%YYYY%-%MM%-%DD% %HH%:%NN%:%SS%" echo Build started: %timestamp% echo. REM Check Python and PyInstaller echo Checking environment... python --version >nul 2>&1 if errorlevel 1 ( echo ERROR: Python is not installed or not in PATH pause exit /b 1 ) pyinstaller --version >nul 2>&1 if errorlevel 1 ( echo WARNING: PyInstaller not found. Installing... pip install pyinstaller if errorlevel 1 ( echo ERROR: PyInstaller installation failed pause exit /b 1 ) ) REM Install psutil for updater pip show psutil >nul 2>&1 if errorlevel 1 ( echo Installing psutil for updater... pip install psutil ) echo OK: Environment ready echo. REM Clean previous builds echo Cleaning previous builds... if exist "dist" rmdir /s /q "dist" if exist "build" rmdir /s /q "build" if exist "app.exe" del "app.exe" if exist "updater.exe" del "updater.exe" if exist "plugins\updater.exe" del "plugins\updater.exe" echo OK: Cleanup complete echo. REM Build updater.exe first echo ==================================================== echo Step 1/3: Building updater.exe echo ==================================================== pyinstaller updater.spec --clean --noconfirm if errorlevel 1 ( echo ERROR: Updater build failed! pause exit /b 1 ) if not exist "dist\updater.exe" ( echo ERROR: updater.exe was not created! pause exit /b 1 ) REM Copy updater.exe to plugins folder echo Copying updater.exe to plugins folder... if not exist "plugins" mkdir "plugins" copy "dist\updater.exe" "plugins\updater.exe" >nul if errorlevel 1 ( echo ERROR: Failed to copy updater.exe to plugins folder pause exit /b 1 ) REM Check updater size for %%I in ("plugins\updater.exe") do set UPDATER_SIZE=%%~zI set /a UPDATER_SIZE_MB=%UPDATER_SIZE%/1024/1024 echo OK: updater.exe built successfully (%UPDATER_SIZE_MB% MB) echo. REM Build app.exe echo ==================================================== echo Step 2/3: Building app.exe (with updater included) echo ==================================================== REM Update app.spec to include updater.exe in plugins echo Updating app.spec to include updater.exe... pyinstaller app.spec --clean --noconfirm if errorlevel 1 ( echo ERROR: App build failed! pause exit /b 1 ) if not exist "dist\app.exe" ( echo ERROR: app.exe was not created! pause exit /b 1 ) REM Copy to current directory echo. echo ==================================================== echo Step 3/3: Finalizing build echo ==================================================== copy "dist\app.exe" "app.exe" >nul copy "dist\updater.exe" "updater.exe" >nul REM Check final sizes for %%I in ("app.exe") do set APP_SIZE=%%~zI set /a APP_SIZE_MB=%APP_SIZE%/1024/1024 echo. echo ==================================================== echo Build Complete! echo ==================================================== echo. echo Build Results: echo -------------- echo app.exe: %APP_SIZE_MB% MB (%APP_SIZE% bytes) echo updater.exe: %UPDATER_SIZE_MB% MB (%UPDATER_SIZE% bytes) echo. echo Files location: echo - app.exe (main application) echo - updater.exe (standalone updater) echo - plugins\updater.exe (embedded in app.exe) echo. echo Build time: %timestamp% echo. echo Next steps: echo 1. Test app.exe locally echo 2. Test update process with updater.exe echo 3. Upload app.exe to server echo 4. Deploy to agent PCs echo. REM Optional: Test run set /p choice="Run app.exe now? (y/N): " if /i "%choice%"=="y" ( echo Starting app.exe... start "" "app.exe" ) else ( echo Run manually: app.exe ) echo. echo Build script completed! pause