windows注册服务

下载Windows Service Wrapper


1. github下载winsw

Winsw

安装windows服务

  1. 2. 将java jar包和下载的WinSW.NET4.exe放在同一个文件夹目录下面

  2.    重命名WinSW.NET4.exe为MyApp.exe(这个可以任意取),新建个MyApp.xml(这个必须和前者的exe文件名字相同)

  3.   MyApp

3. 编辑MyApp.xml文件

<configuration>
    <id>MyApp</id>
    <name>MyApp</name>
    <description>This is MyApp.</description>
    
    <executable>java</executable>
    <arguments>-jar C:\Users\tanhw119214\Desktop\MyApp\MyApp.jar</arguments>
      <!-- 开机启动 -->
     <startmode>Automatic</startmode>
    <logpath>C:\Users\tanhw119214\Desktop\MyApp\logs</logpath>
    <log mode="roll-by-time">
    <pattern>yyyyMMdd</pattern>
    </log>
</configuration>
C:\Users\tanhw119214\Desktop\MyApp 为你要要注册服务的文件的父路径


4.进入根目录下面,执行以下cmd命令,注册服务。然后在服务里面就能找到这个实例了。

  • 启动命令

net start MyApp1
  • 停止命令

net stop MyApp1
  • 卸载命令

sc delete MyApp


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章