winsw

将一个应用程序安装为windows服务

可以将一个应用程序或脚本封装为windows服务端的程序有, sc create命令,nssm 程序, winsw程序 ,好像还有procrun

sc create使用

转载来源:https://blog.51cto.com/u_13766198/4638481

将bat 加入服务:

格式:
sc create ServiceName binPath= 路径 start= auto

winsw使用

github中查找项目,下载。

winsw.exe 改名为xxx.exe

winsw.xml改名为xxx.xml,为配置文件

修改xxx.xml

<!--
    Copyright (c) 2016 Oleg Nenashev and other contributors

    Permission is hereby granted, free of charge, to any person obtaining a copy of this 
    software and associated documentation files (the "Software"), to deal in the Software without
    restriction, including without limitation the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or 
    substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
    BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
    DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->

<!--
 This is an example of a minimal Windows Service Wrapper configuration, which includes only mandatiory options.
 
 This configuration file should be placed near the WinSW executable, the name should be the same.
 E.g. for myapp.exe the configuration file name should be myapp.xml
 
 You can find more information about the configuration options here: https://github.com/kohsuke/winsw/blob/master/doc/xmlConfigFile.md
 Full example: https://github.com/kohsuke/winsw/blob/sample-config-file/examples/allOptions.xml
-->
<configuration>
  
  <!-- ID of the service. It should be unique accross the Windows system-->
  <id>kibana</id>
  <!-- Display name of the service -->
  <name>kibana</name>
  <!-- Service description -->
  <description>kibana service</description>
  
  <!-- Path to the executable, which should be started -->
  <executable>C:\standalone\kibana-8.7.1\bin\kibana.bat</executable>
  <!--<arguments></arguments>-->
  <log mode="none"/>
  <!--<interactive />--><!-- 目前来看,如果启动的是个bat,而且执行完毕不要退出(类似 cmd /k),需要加此参数; 或者有gui界面 -->

</configuration>

评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注