注册成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

启动或停止服务:

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

相关推荐
阿白的白日梦4 天前
winget基础管理---更新/修改源为国内源
windows
埃博拉酱8 天前
VS Code Remote SSH 连接 Windows 服务器卡在"下载 VS Code 服务器":prcdn DNS 解析失败的诊断与 BITS 断点续传
windows·ssh·visual studio code
唐宋元明清21889 天前
.NET 本地Db数据库-技术方案选型
windows·c#
加号39 天前
windows系统下mysql多源数据库同步部署
数据库·windows·mysql
tryCbest9 天前
Windows环境下配置pip镜像源
windows·pip
呉師傅9 天前
火狐浏览器报错配置文件缺失如何解决#操作技巧#
运维·网络·windows·电脑
百事牛科技9 天前
保护文档安全:PDF限制功能详解与实操
windows·pdf
一个人旅程~9 天前
如何用命令行把win10/win11设置为长期暂停更新?
linux·windows·经验分享·电脑
一个假的前端男9 天前
[特殊字符] Flutter 安装完整指南 Windows—— 2026最新版
windows·flutter
倚肆9 天前
在 Windows Docker 中安装并配置 Nginx (映射 Windows 端口与路径)
windows·nginx·docker