nssm注册windows服务

烂柯 发布于 2023-03-23 166 次阅读


nssm是一个windows服务封装程序,可以将exe等程序封装成服务,微软自己有srvany

一、下载NSSM

官方源码地址:https://git.nssm.cc/nssm/nssm

官方下载地址:https://nssm.cc/download

二、安装服务

方法 一、GUI安装

nssm install 唤起GUI,通过页面配置安装window服务

方法二、命令安装

#1、添加服务 
# nssm install <服务名> <安装路径>
nssm install test "E:\consul.exe"

#2、设置服务
#设置应用入口
#nssm set <服务名> Application "E:\consul.exe" 对应GUI 
#设置工作目录
#nssm set <服务名> AppDirectory "E:"
#设置启动参数
#nssm set <服务名> AppParameters "agent -client 0.0.0.0 -dev"
nssm set test AppParameters "agent -client 0.0.0.0 -dev"

三、启动&停止服务

#开启服务  nssm start <服务名> 或 sc start <服务名> 
nssm start test
#关闭服务  nssm stop <服务名> 或 sc stop <服务名> 
nssm stop test
#重启服务  nssm restart <服务名>
nssm restart test

四、删除服务

#卸载服务 nssm remove <服务名> confirm  或 sc delete test
nssm remove test confirm
#confirm:不会唤起GUI进行确认操作
烂柯

最后更新于 2023-03-23