创建安装路径中带有空格的服务

发布于 2024-11-28 09:41:14 字数 1764 浏览 5 评论 0原文

我正在使用 Apache 的 procrun 创建 Windows 服务,但很难正确设置它。我正在使用批处理文件来执行 procrun 安装。我的问题有两个方面。

  1. 我无法创建名称中包含空格的服务。此示例取自 Apache,正在设置 prunsrv 服务安装:

    prunsrv //IS//TestService --DisplayName="测试服务" \
        --安装=prunsrv.exe --Jvm=auto --StartMode=jvm --StopMode=jvm \
        --StartClass=org.apache.SomeStartClass --StartParams=arg1;arg2;arg3 \
        --StopClass=org.apache.SomeStopClass --StopParams=arg1#arg2
    

    我在 C:\Program Files\ 某处安装了一个服务,其中有一个空格。我需要 --Install 路径为“C:\Program Files\prunsrv.exe”才能正确指向正确的路径。如果我不将路径用引号引起来:

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

    Windows服务认为安装路径是:

    <前><代码>C:\程序

    这是一个无效位置。当我使用时:

    --Install="C:\Program Files\prunsrv.exe"(或) 
    “--安装=C:\Program Files\prunsrv.exe”
    

    Windows服务认为安装路径是:

    <前><代码>“C:\ Program Files \ prunsrv.exe”

    ...这也是一个无效位置(它实际上尝试使用引号执行该路径。)

    有人知道如何正确安装路径中包含空格的 Windows 服务吗?

  2. 如果出现进一步的复杂情况,最好有更详细的文档。有谁有 procrun 的任何附加文档或使用它的示例吗?到目前为止我找到的资源列表是:

    其他问题中使用的好资源似乎不再可用: http://blog.platinumsolutions.com/node/234

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:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三生一梦 2024-12-05 09:41:14

对于问题#1,您可以尝试使用仅包含短名称的等效路径。可以借助 FOR 循环转换长名称路径:

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

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 2024-12-05 09:41:14

我知道这是旧的,但不太聪明的解决方案是:

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

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

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%

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文