原理:使用winsw将shell命令包成服务并设置开机自启动
winsw github地址:https://github.com/winsw/winsw/releases/tag/v2.11.0
下载后将winsw.exe
(WinSW-x64.exe
重命名后的名称为winsw.exe
)放在和frp同级目录
新建xml文件命名为winsw.xml
,进行配置,如下:
<service>
<id>frpc</id>
<name>frpc</name>
<description>frpc服务</description>
<executable>frpc</executable>
<arguments>-c frpc.ini</arguments>
<logmode>reset</logmode>
</service>
文件结构如下图所示:
运行命令:
# 安装服务
winsw.exe install
# 卸载服务
winsw.exe uninstall