软件运行需要.Net Framework软件环境,根据需要下载,一般情况windows是有这个环境的,查看方法 在地址栏上输入C:\Windows\Microsoft.NET\Framework ,按回车键即可查看,缺失下载安装。
然后下载 sample-minimal.xml 配置文件
将这两个文件和 server.exe(node打的exe程序) 放到同一个目录
修改 sample-minimal.xml 配置文件
<service>
<!-- ID of the service. It should be unique across the Windows system-->
# 安装windows服务后的服务ID,必须是唯一的。
<id>nodeStart</id>
<!-- Display name of the service -->
# 服务名称,必须是唯一的。一般和id一致即可。
<name>nodeStart</name>
<!-- Service description -->
# 服务描述,可做备注使用。
<description>nodeStart</description>
<!-- Path to the executable, which should be started -->
# 执行的命令
<executable>%BASE%\server.exe</executable>
# 日志输出
<logpath>%BASE%\serviceLogs</logpath>
</service>然后新建两个 bat文件
install.bat
@echo off
start cmd /k "nodeStart.exe install"
exituninstall.bat
@echo off
start cmd /k "nodeStart.exe uninstall"
exit上述exe程序为 下载的winsw程序包, 我更改了包名
然后运行 install 即可设置开机自启动
PS:这里的bat涉及windows的批处理命令,而对于开机启动项等敏感位置,会有安全软件进行拦截或报警提示,放行即可。