windowsprocrun

Apache prunsrv: error parsing command line


I'm trying to start a Java program as a Windows Service. Googling I've found a install.bat to install and start my service.

As I found on the Internet, I've renamed prunsrv.exe to IdentificationService.exe.

D:\IdentificationService\bin\IdentificationService.exe //IS//IdentificationService
D:\IdentificationService\bin\IdentificationService.exe //US//IdentificationService --Install=D:\IdentificationService\bin\IdentificationService.exe --Description= Identification Service --Jvm="C:\Program Files (x86)\\Diginet\java\bin\server\jvm.dll" --Classpath=D:\IdentificationService\lib --StartMode=jvm --StartClass=br.com..digis.DiginetIdentificationService --StartMethod=start --StartParams=start --StopMode=jvm --StopClass=br.com..digis.DiginetIdentificationService --StopMethod=stop --StopParams=stop --LogPath=D:\IdentificationService\logs --StdOutput=auto --StdError=auto
net start IdentificationService

My problem is that each time I execute IdentificationService it says "Error parsing command line".

I've tried to enclose all parameters by double quotes. Same results.

I've tried to use the original prunsrv.exe withou renaming it. Same results.

What am I missing?


Solution

  • Try setting the parameters through the environment variables

    set SERVICE_NAME=CsvToXmlService
    set PR_INSTALL=%cd%\prunsrv.exe
    set PR_DESCRIPTION=CsvToXml Service
    
    REM Service log configuration
    set PR_LOGPREFIX=%SERVICE_NAME%
    set PR_LOGPATH=%cd%
    set PR_STDOUTPUT=%cd%\stdout.txt
    set PR_STDERROR=%cd%\stderr.txt
    set PR_LOGLEVEL=Error
    
    REM Path to java installation
    set PR_JVM=C:\Program Files\Java\jre7\bin\server\jvm.dll
    set PR_CLASSPATH=%cd%\target\app.jar
    
    REM Startup configuration
    set PR_STARTUP=auto
    set PR_STARTMODE=jvm
    set PR_STARTCLASS=ru.misterparser.csvtoxmlservice.Main
    set PR_STARTMETHOD=start
    
    REM Shutdown configuration
    set PR_STOPMODE=jvm
    set PR_STOPCLASS=ru.misterparser.csvtoxmlservice.Main
    set PR_STOPMETHOD=stop
    
    REM JVM configuration
    set PR_JVMMS=256
    set PR_JVMMX=1024
    set PR_JVMSS=4000
    set PR_JVMOPTIONS=-Duser.language=RU;-Duser.region=ru
    
    REM Install service
    prunsrv.exe //IS//%SERVICE_NAME%
    
    sc start %SERVICE_NAME%