I currently developed an Eclipse application which also has a headless build available to integrate with some other application. We created a .exe for our application. What I need is when the installation of our application is completed the headless build should be register as window service. The headless build is started using a batch file which contains following :
set WORKSPACE=
java -jar plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar -pluginCustomization plugin_customization.ini -application myapplication.app.HEADLESSAPP -data %WORKSPACE% -noExit -isHeadLess
When we run this .bat file it starts our application in Non UI mode.
I tried following things so far:
sc.exe
command but this didn't work..exe
and then tried sc.exe
(give error 1053) and NSSM
(executable path always refer to nssm.exe instead of my application).So basically I need a way to to register this .bat
or .exe
file as windows service so that it launch my headless application.
UPDATE :
Tried this :
set SERVICE_NAME=TESTSERVICE
set SERVICE_TITLE="TESTSERVICE"
set ECLIPSE_DIR=%~dp0
"%~dp0TESTSERVICE.exe" install %SERVICE_TITLE% --Startup=auto --StartMode=java --StartImage="%ECLIPSE_DIR%eclipsec.exe" --StartPath="%ECLIPSE_DIR%\" ++StartParams="-noSplash -pluginCustomization plugin_customization.ini -application com.eu.ales.hvac.ipm.headless.app.HEADLESSIPMDT -data \"%ECLIPSE_DIR%workspace\" -configuration \"%ECLIPSE_DIR%configuration\"" --LogPath="%ECLIPSE_DIR%\" --LogLevel="Error" --LogPrefix="service"
but getting this
To run a headless Eclipse RCP application as Windows service I use successfully Apache Commons' prunsrv.exe (download here) for several years.
Step-by-step instruction to run Eclipse Infocenter (which is a headless RCP application and contained in all Eclipse IDE packages) as Windows service:
In the Eclipse installation directory create the file install_as_service.bat
with following content:
set INFOCENTER_PORT=8088
set INFOCENTER_TITLE="Eclipse Infocenter"
for %%i in ("%~dp0") do (set INFOCENTER_DIR=%%~dpi)
set INFOCENTER_DESCRIPTION=Port: %INFOCENTER_PORT%, Location: %INFOCENTER_DIR%
"%~dp0\prunsrv.exe" install %INFOCENTER_TITLE% --Description="%INFOCENTER_DESCRIPTION% " --Startup=auto --StartMode=exe --StartImage="%INFOCENTER_DIR%eclipsec.exe" --StartPath="%INFOCENTER_DIR%\" ++StartParams="-noSplash#-application#org.eclipse.help.base.infocenterApplication#-data#\"%INFOCENTER_DIR%info_center_workspace\"#-configuration#\"%INFOCENTER_DIR%info_center_configuration\"#-vmargs#-Dserver_port=%INFOCENTER_PORT%#-Xms420m#-Xmx420m#-XX:MaxPermSize=256m" --StopMode=exe --StopTimeout=300 --StopImage="%INFOCENTER_DIR%eclipsec.exe" --StopPath="%INFOCENTER_DIR%\" ++StopParams="-noSplash#-application#org.eclipse.help.base.infocenterApplication#-data#\"%INFOCENTER_DIR%info_center_workspace\"#-configuration#\"%INFOCENTER_DIR%info_center_configuration\""#-command#shutdown --LogPath="%INFOCENTER_DIR%\" --LogLevel="Error" --LogPrefix="service"
Double-click install_as_service.bat
services.msc
and click OK
To uninstall the service, first stop the service and then run prunsrv.exe delete "Eclipse Infocenter"