1

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?

Nilo Paim
  • 428
  • 6
  • 22

2 Answers2

1

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%
  • That way it works, but procrun site says that I can use a single line command with the same results. That's not what is happening. Anyway, thanks for your answer. – Nilo Paim Mar 13 '17 at 17:10
1

rename exe back to prunsrv and run it with exactly same parameters (except first exe ofc)

BStolarski
  • 11
  • 1
  • It was a long time ago. Since then, the service was rewritten using C# and works very well. Anyway, I tried your suggestion on an old backup I've found. "Error parsing command line" persists. Thanks for your answer. – Nilo Paim Jul 31 '19 at 18:25