我试图启动一个Java程序作为Windows服务。我找到了一个install.bat来安装和启动我的服务。
正如我在Internet上发现的,我已将prunsrv.exe重命名为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

我的问题是,每次执行identificationservice时,它都会说“解析命令行时出错”。
我试图用双引号将所有参数括起来。同样的结果。
我试图在重命名的情况下使用原始的prunsrv.exe。同样的结果。
我错过了什么?

最佳答案

尝试通过环境变量设置参数

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%

关于windows - Apache prunsrv:命令行解析错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42375331/

10-11 00:09