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

启动或停止服务:

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

相关推荐
sR916Mecz37 分钟前
pache Hop实战:Windows平台MySQL数据迁移的深度排错与性能调优
数据库·windows·mysql
小白电脑技术1 小时前
Windows家庭版开启原生远程桌面
windows
扑火的小飞蛾2 小时前
Windows 10 与 Kali Linux SSH 免密互信配置指南
linux·windows·ssh
Chris _data3 小时前
从宿主机(Windows)通过 NAT 模式连接虚拟机(Ubuntu)中的 MySQL
windows·mysql·ubuntu
高兴就好20484 小时前
ClaudeCode在windows 11安装方法(2026年4月)
windows
公子小六4 小时前
基于.NET的Windows窗体编程之WinForms布局简介
windows·microsoft·c#·.net
众创岛4 小时前
windows下的一些命令汇总
windows
塞北山巅5 小时前
Windows 下基于 MSYS2 搭建 C++ 开发环境:从安装到配置全指南
开发语言·c++·windows
SuniaWang5 小时前
2026 AI Agent 爆发元年:OpenClaw v2026.4.2(The Lobster)Windows 深度部署与全路径避坑指南
人工智能·windows·openclaw·小龙虾
HUGu RGIN5 小时前
SQLMAP的下载安装和使用(Windows)
windows