createed a good service
This commit is contained in:
@@ -38,33 +38,71 @@ echo.
|
|||||||
echo Copying service files...
|
echo Copying service files...
|
||||||
copy /Y "%~dp0print_service.ps1" "%SERVICE_DIR%\print_service.ps1"
|
copy /Y "%~dp0print_service.ps1" "%SERVICE_DIR%\print_service.ps1"
|
||||||
if %errorLevel% neq 0 (
|
if %errorLevel% neq 0 (
|
||||||
echo ❌ Error copying service files!
|
echo ❌ Error copying PowerShell service file!
|
||||||
echo Make sure print_service.ps1 is in the same directory as this installer.
|
echo Make sure print_service.ps1 is in the same directory as this installer.
|
||||||
pause
|
pause
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
copy /Y "%~dp0service_wrapper.bat" "%SERVICE_DIR%\service_wrapper.bat"
|
||||||
|
if %errorLevel% neq 0 (
|
||||||
|
echo ❌ Error copying service wrapper file!
|
||||||
|
echo Make sure service_wrapper.bat is in the same directory as this installer.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
echo ✅ Service files copied successfully
|
echo ✅ Service files copied successfully
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Checking for existing service...
|
||||||
|
sc query "%SERVICE_NAME%" >nul 2>&1
|
||||||
|
if not errorlevel 1 (
|
||||||
|
echo ⚠️ Service already exists. Removing existing service first...
|
||||||
|
sc stop "%SERVICE_NAME%" >nul 2>&1
|
||||||
|
sc delete "%SERVICE_NAME%" >nul 2>&1
|
||||||
|
timeout /t 2 /nobreak >nul
|
||||||
|
)
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo Installing Windows Service...
|
echo Installing Windows Service...
|
||||||
|
|
||||||
REM Create the Windows service
|
REM Create the Windows service with corrected syntax
|
||||||
sc create "%SERVICE_NAME%" ^
|
echo Creating service: %SERVICE_NAME%
|
||||||
binpath="powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File \"%SERVICE_DIR%\print_service.ps1\"" ^
|
echo Binary path: %SERVICE_DIR%\service_wrapper.bat
|
||||||
start=auto ^
|
echo.
|
||||||
displayname="Quality Recticel Print Service" ^
|
|
||||||
description="Local HTTP service for silent PDF printing from Quality Recticel web application"
|
|
||||||
|
|
||||||
|
sc create %SERVICE_NAME% binPath="%SERVICE_DIR%\service_wrapper.bat" start=auto DisplayName="Quality Recticel Print Service"
|
||||||
|
|
||||||
|
REM Check if service creation succeeded
|
||||||
|
sc query %SERVICE_NAME% >nul 2>&1
|
||||||
if errorlevel 1 (
|
if errorlevel 1 (
|
||||||
echo ❌ Failed to create Windows service
|
echo ❌ Service creation verification failed
|
||||||
echo.
|
goto :service_error
|
||||||
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 ✅ Service created successfully
|
||||||
|
|
||||||
|
REM Set description (may fail on older Windows, that's OK)
|
||||||
|
sc description %SERVICE_NAME% "Local HTTP service for silent PDF printing from Quality Recticel web application" >nul 2>&1
|
||||||
|
|
||||||
|
goto :service_created
|
||||||
|
|
||||||
|
:service_error
|
||||||
|
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%
|
||||||
|
echo.
|
||||||
|
echo Manual commands to try:
|
||||||
|
echo sc create %SERVICE_NAME% binPath="\"%SERVICE_DIR%\service_wrapper.bat\""
|
||||||
|
echo sc config %SERVICE_NAME% start=auto
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
|
||||||
|
:service_created
|
||||||
echo ✅ Windows service created successfully
|
echo ✅ Windows service created successfully
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
|
|||||||
149
windows_print_service/install_simple.bat
Normal file
149
windows_print_service/install_simple.bat
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
@echo off
|
||||||
|
REM Quality Recticel Print Service - Simple Native Installation
|
||||||
|
REM This version uses the most basic approach to avoid command line parsing issues
|
||||||
|
|
||||||
|
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 this file 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...
|
||||||
|
|
||||||
|
REM Copy PowerShell service file
|
||||||
|
if not exist "%~dp0print_service.ps1" (
|
||||||
|
echo ❌ print_service.ps1 not found in installer directory
|
||||||
|
echo Make sure all service files are in the same folder as this installer
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
copy /Y "%~dp0print_service.ps1" "%SERVICE_DIR%\print_service.ps1"
|
||||||
|
echo ✅ PowerShell service copied
|
||||||
|
|
||||||
|
REM Create a simple service executable using PowerShell
|
||||||
|
echo Creating service executable...
|
||||||
|
echo @echo off > "%SERVICE_DIR%\start_service.bat"
|
||||||
|
echo cd /d "%SERVICE_DIR%" >> "%SERVICE_DIR%\start_service.bat"
|
||||||
|
echo powershell.exe -ExecutionPolicy Bypass -NoProfile -File "print_service.ps1" >> "%SERVICE_DIR%\start_service.bat"
|
||||||
|
|
||||||
|
echo ✅ Service files prepared
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Removing any existing service...
|
||||||
|
sc query "%SERVICE_NAME%" >nul 2>&1
|
||||||
|
if not errorlevel 1 (
|
||||||
|
echo Found existing service, removing it...
|
||||||
|
sc stop "%SERVICE_NAME%" >nul 2>&1
|
||||||
|
timeout /t 2 /nobreak >nul
|
||||||
|
sc delete "%SERVICE_NAME%" >nul 2>&1
|
||||||
|
timeout /t 2 /nobreak >nul
|
||||||
|
echo ✅ Existing service removed
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Installing Windows Service...
|
||||||
|
echo Command: sc create %SERVICE_NAME% binPath="%SERVICE_DIR%\start_service.bat"
|
||||||
|
echo.
|
||||||
|
|
||||||
|
REM Create service with absolute minimal parameters
|
||||||
|
sc create "%SERVICE_NAME%" binPath="%SERVICE_DIR%\start_service.bat"
|
||||||
|
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo.
|
||||||
|
echo ❌ Service creation failed. Let's try troubleshooting...
|
||||||
|
echo.
|
||||||
|
echo Checking sc command availability:
|
||||||
|
sc /?
|
||||||
|
echo.
|
||||||
|
echo Current user context:
|
||||||
|
whoami
|
||||||
|
echo.
|
||||||
|
echo Trying alternative service creation method:
|
||||||
|
sc create TestService binPath="cmd.exe /c echo test"
|
||||||
|
sc delete TestService >nul 2>&1
|
||||||
|
echo.
|
||||||
|
echo If the above worked, the issue is with our service path.
|
||||||
|
echo If it failed, there's a deeper Windows service issue.
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo ✅ Service created successfully
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Configuring service startup...
|
||||||
|
sc config "%SERVICE_NAME%" start=auto
|
||||||
|
sc config "%SERVICE_NAME%" DisplayName="Quality Recticel Print Service"
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Starting the service...
|
||||||
|
sc start "%SERVICE_NAME%"
|
||||||
|
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo ⚠️ Service created but failed to start
|
||||||
|
echo This is normal - let's check what happened...
|
||||||
|
echo.
|
||||||
|
echo Service status:
|
||||||
|
sc query "%SERVICE_NAME%"
|
||||||
|
echo.
|
||||||
|
echo You can start it manually later with: sc start %SERVICE_NAME%
|
||||||
|
) else (
|
||||||
|
echo ✅ Service started successfully
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo Testing service connectivity...
|
||||||
|
timeout /t 3 /nobreak >nul
|
||||||
|
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://localhost:8765/health' -TimeoutSec 5; Write-Host '✅ Service is responding: ' $response.StatusCode } catch { Write-Host '⚠️ Service not responding yet (this is normal, may need a few seconds)' }"
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ================================================
|
||||||
|
echo Installation Summary
|
||||||
|
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 Service Management Commands:
|
||||||
|
echo Start: sc start %SERVICE_NAME%
|
||||||
|
echo Stop: sc stop %SERVICE_NAME%
|
||||||
|
echo Status: sc query %SERVICE_NAME%
|
||||||
|
echo Delete: sc delete %SERVICE_NAME%
|
||||||
|
echo.
|
||||||
|
echo Next Steps:
|
||||||
|
echo 1. Wait 10-30 seconds for service to fully start
|
||||||
|
echo 2. Test: Open http://localhost:8765/health in your browser
|
||||||
|
echo 3. Install Chrome extension if needed
|
||||||
|
echo 4. Test printing from Quality Recticel web application
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
4
windows_print_service/service_wrapper.bat
Normal file
4
windows_print_service/service_wrapper.bat
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
@echo off
|
||||||
|
REM Service wrapper for PowerShell print service
|
||||||
|
cd /d "C:\Program Files\QualityRecticel\PrintService"
|
||||||
|
powershell.exe -ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File "print_service.ps1"
|
||||||
Reference in New Issue
Block a user