开发者

Creation of service with spaces in install path

I am creating a Windows service using Apache's procrun, and I'm having difficulty getting it set up properly. I'm using a batch file to execute the开发者_开发百科 procrun install. My question is two fold.

  1. I'm unable to create a service with spaces in the name. This example was taken from Apache and is setting up a prunsrv service install:

    prunsrv //IS//TestService --DisplayName="Test Service" \
        --Install=prunsrv.exe --Jvm=auto --StartMode=jvm --StopMode=jvm \
        --StartClass=org.apache.SomeStartClass --StartParams=arg1;arg2;arg3 \
        --StopClass=org.apache.SomeStopClass --StopParams=arg1#arg2
    

    I have an installed service somewhere in C:\Program Files\, which has a space. I need the --Install path to be 'C:\Program Files\prunsrv.exe' to correctly point to the right path. If I don't inclose the path with quotes:

    --Install=C:\Program Files\prunsrv.exe
    

    Windows service thinks the install path is:

    C:\Program
    

    Which is an invalid location. When I use:

    --Install="C:\Program Files\prunsrv.exe"  (or) 
    "--Install=C:\Program Files\prunsrv.exe"
    

    Windows service thinks the install path is:

    "C:\Program Files\prunsrv.exe"
    

    ...which is also an invalid location (it literally tries to execute that path with the quotes.)

    Does anyone know how to correctly install a Windows service with spaces in the path?

  2. If further complications arise, it would be nice to have more detailed documentation. Does anyone have any additional documentation for procrun or examples of it being used? The list of resources I have found this far is:

    • http://commons.apache.org/daemon/procrun.html
    • http://srsprasad.blogspot.com/2010/04/converting-java-class-to-windows.html
    • http://kickjava.com/src/org/apache/commons/daemon/SimpleDaemon.java.htm

    It looks like a good resource used in other questions is no longer available: http://blog.platinumsolutions.com/node/234


For the question #1, you could try using the equivalent path consisting only of short names. It is possible to convert a long-name path with the help of a FOR loop:

FOR %%F IN ("C:\Program Files\prunsrv.exe") DO SET prunsrv=%%~sF
prunsrv … --Install=%prunsrv% …


I know this is old but a bit less clever solution is:

set JVM_DLL="c:\Program Files\Java\jre6\bin\server\jvm.dll"

prunsrv //IS//%SERVICE_NAME% --Jvm=%JVM_DLL%

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜