Windows添加自定义服务

1.新建文件
新建xml文件 命名 Name-service.xml

<service>
  
  <!-- ID of the service. It should be unique across the Windows system-->
  <id>ServerID</id>
  <!-- Display name of the service -->
  <name>ServerName</name>
  <!-- Service description -->
  <description>ServerDescription</description>
  
  <!-- Path to the executable, which should be started -->
  <executable>D:\Name.exe</executable>

</service>

里面存放以上内容

2.下载应用

下载链接: https://github.com/winsw/winsw/releases/tag/v2.11.0

3.安装服务
将下载的文件名称改为新建的xml名称,将此文件移到xml里面配置的项目路径中
在当前目录下 CMD进入目录,然后执行命令
Name-service.exe install
系统成功了有提示,失败请看提示或相关log文件

4.启动服务

到windows service里面找到 使用启动按钮, 编辑按钮设置为 自动启动
启动失败一般是端口被占用,需要去修改 或看log 去解决
一般错误都是程序使用错误自行排查

posted on   糯米白白  阅读(1325)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示