创建安装路径中带有空格的服务
我正在使用 Apache 的 procrun 创建 Windows 服务,但很难正确设置它。我正在使用批处理文件来执行 procrun 安装。我的问题有两个方面。
我无法创建名称中包含空格的服务。此示例取自 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 服务吗?
如果出现进一步的复杂情况,最好有更详细的文档。有谁有 procrun 的任何附加文档或使用它的示例吗?到目前为止我找到的资源列表是:
- 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
其他问题中使用的好资源似乎不再可用: 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.
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?
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于问题#1,您可以尝试使用仅包含短名称的等效路径。可以借助
FOR
循环转换长名称路径: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:我知道这是旧的,但不太聪明的解决方案是:
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%