@echo off REM Quality Recticel Print Service - Windows Native Installation REM This script creates a lightweight PowerShell-based print service echo ================================================ echo Quality Recticel Print Service - Native Windows echo ================================================ echo. REM Check if running as administrator net session >nul 2>&1 if %errorLevel% NEQ 0 ( echo ERROR: This script must be run as Administrator! echo Right-click on install_native_service.bat and select "Run as administrator" pause exit /b 1 ) echo ✅ Administrator privileges confirmed echo. REM Service configuration set SERVICE_NAME=QualityRecticelPrintService set SERVICE_DIR=C:\Program Files\QualityRecticel\PrintService echo Creating service directory: %SERVICE_DIR% if not exist "%SERVICE_DIR%" ( mkdir "%SERVICE_DIR%" 2>nul if errorlevel 1 ( echo ❌ Failed to create service directory pause exit /b 1 ) ) echo ✅ Service directory created echo. echo Copying service files... copy /Y "%~dp0print_service.ps1" "%SERVICE_DIR%\print_service.ps1" if %errorLevel% neq 0 ( echo ❌ Error copying service files! echo Make sure print_service.ps1 is in the same directory as this installer. pause exit /b 1 ) echo ✅ Service files copied successfully echo. echo Installing Windows Service... REM Create the Windows service sc create "%SERVICE_NAME%" ^ binpath="powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File \"%SERVICE_DIR%\print_service.ps1\"" ^ start=auto ^ displayname="Quality Recticel Print Service" ^ description="Local HTTP service for silent PDF printing from Quality Recticel web application" if errorlevel 1 ( echo ❌ Failed to create Windows service echo. echo Troubleshooting: echo 1. Make sure you're running as Administrator echo 2. Check if the service already exists: sc query %SERVICE_NAME% echo 3. If it exists, delete it first: sc delete %SERVICE_NAME% pause exit /b 1 ) echo ✅ Windows service created successfully echo. echo Configuring service recovery options... sc failure "%SERVICE_NAME%" reset=30 actions=restart/5000/restart/5000/restart/5000 echo. echo Starting the service... sc start "%SERVICE_NAME%" if errorlevel 1 ( echo ⚠️ Service created but failed to start automatically echo You can start it manually from Services (services.msc) echo Or run: sc start %SERVICE_NAME% ) else ( echo ✅ Service started successfully ) echo. echo Checking service status... sc query "%SERVICE_NAME%" | find "RUNNING" >nul if errorlevel 1 ( echo ⚠️ Service is not running. Check the log file for details. ) else ( echo ✅ Service is running properly ) echo. echo ================================================ echo Installation Complete! echo ================================================ echo. echo Service Name: %SERVICE_NAME% echo Service Directory: %SERVICE_DIR% echo Service URL: http://localhost:8765 echo Log File: %SERVICE_DIR%\print_service.log echo. echo Testing endpoints: echo Health Check: http://localhost:8765/health echo Printers: http://localhost:8765/printers echo Print PDF: POST to http://localhost:8765/print/pdf echo. echo To manage the service: echo Start: sc start %SERVICE_NAME% echo Stop: sc stop %SERVICE_NAME% echo Delete: sc delete %SERVICE_NAME% echo Status: sc query %SERVICE_NAME% echo Restart: sc stop %SERVICE_NAME% ^&^& sc start %SERVICE_NAME% echo. echo Next Steps: echo 1. Install the Chrome extension from the Quality Recticel system echo 2. Test printing from the web application echo 3. Check the log file if there are any issues echo. pause