注册成Windows服务

目录

前言

winsw下载地址

注册服务

安装服务

卸载

启动或停止服务:


前言

当我们在Windows上使用cmd启动服务,或者使用"startup.bat"启动项目是都会打开一个黑窗口,容易被其他人意外关闭,导致服务关闭。为了解决这样的尴尬的误会,我们可以使用winserver把我们的应用或者项目注册成一个服务。

winsw下载地址

Releases · winsw/winsw · GitHubA wrapper executable that can run any executable as a Windows service, in a permissive license. - Releases · winsw/winswhttps://github.com/winsw/winsw/releases

github.comhttps://github.com/winsw/winsw/releases/download/v2.12.0/WinSW-x64.exe

注册服务

  • 将上一步下载好的WinSW.exe复制到自定义的目录
  • 同目录下创建projectName.xml

projectName.xml配置如下:

复制代码
<service>
	<!-- 服务自定义ID:唯一的,不能有汉字-->
  <id>high-server</id>
	<!-- 服务自定义名称:与Id一致就好-->
  <name>high-server</name>
  <!-- 服务描述-->
  <description>high的项目</description>
  <!-- 要执行的命令-->
  <executable>java</executable>
 <!-- 命令执行参数-->
  <arguments>-jar D:\services\tourism-monitoring-platform-test-1.0.0\tourism-monitoring-platform\boot\tourism-monitoring-platform.jar</arguments>

  <log mode="reset"/>
</service>

安装服务

server.exe install

卸载

server.exe uninstall

启动或停止服务:

安装好服务后,我们就可以在这里启动或者停止服务了。

相关推荐
爱吃火鸡面呀13 小时前
Spark RDD 行动算子(Action)详解
windows·ajax·spark
dlhto13 小时前
Windows 使用 Rufus 制作 AlmaLinux 10.2 启动 U 盘:从 ISO 下载到服务器安装
运维·服务器·windows
小矮强14 小时前
输入凭证也没用?Windows 共享文件夹“来宾访问被安全策略阻止”
windows·经验分享
skywalk816315 小时前
Virtualbox 从7.2.20降级到7.2.18 @FreeBSD系统
windows·virtualbox·freebsd
DogDaoDao15 小时前
Windows 双 Shell 全面对比:CMD 与 PowerShell 的技术剖析
windows·shell·测试·powershell·cmd·程序员开发
长不大的杨瑞杰15 小时前
Windows 安装 OpenCode v2:原生、WSL、Desktop 怎么选?完整配置与避坑指南
人工智能·windows·ai agent·opencode
Misnice17 小时前
Python 内置函数大全
开发语言·windows·python
运维踩坑日记19 小时前
【无标题】
linux·运维·windows
小米渣的逆袭19 小时前
Windows 键盘触发蓝屏获取内存转储(Dump)操作文档
windows