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

启动或停止服务:

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

相关推荐
像风一样自由20201 小时前
从本地到公网:Windows 下使用 Cloudflare Quick Tunnel 与 Natapp 联调 FastAPI
windows·fastapi
2601_960906727 小时前
科技“无人区”跋涉,难度高、不确定性大
windows·macos·pycharm·myeclipse
会飞的大鱼人8 小时前
一文搞懂 Java HashSet:把它想成游乐园里只允许一次入场的盖章名单
java·开发语言·windows
ziguo11229 小时前
C/C++ 错误处理全解:从 errno 到 C++ 异常
linux·c语言·c++·windows·visual studio
王维同学10 小时前
IFEO Debugger、VerifierDlls 与 SilentProcessExit 配置
c++·windows·安全·注册表
您^_^12 小时前
使用技巧(十一):Claude Code 最强审问官 —— grill-me 深度指南,装完先别写代码
人工智能·windows·个人开发·claudecode·deepseek v4 pro
酉鬼女又兒13 小时前
[特殊字符]零基础入门AI:归纳演绎、假设空间、归纳偏好、NFL、过拟合与欠拟合、模型评估选择、超参数、性能度量、混淆矩阵、P-R曲线和F1
人工智能·windows·python·深度学习·安全·机器学习·矩阵
山城码农笑松哥14 小时前
C盘空间救星:一键无损迁移软件数据到其他盘
windows·c盘清理迁移
WangWei_CM14 小时前
IFEO Debugger、VerifierDlls 与 SilentProcessExit 配置
windows
spencer_tseng1 天前
Redis + Nacos.bat
java·windows·dos