1、到 https://github.com/winsw/winsw/releases/tag/v2.12.0 下载对应版本的.exe文件,我下载的是x64版本。
2、把 WinSW-x64.exe 重命名为一个有意义的名字,如 frpc-service.exe 。
3、在 frpc-service.exe 所在目录下,新建 frpc_service.xml 。

4、frpc_service.xml 的内容:

<!--
  MIT License

  Copyright (c) 2008-2020 Kohsuke Kawaguchi, Sun Microsystems, Inc., CloudBees,
  Inc., Oleg Nenashev and other contributors

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
-->

<!--
 This is an example of a minimal Windows Service Wrapper configuration, which includes only mandatory options.
 
 This configuration file should be placed near the WinSW executable, the name should be the same.
 E.g. for myapp.exe the configuration file name should be myapp.xml
 
 You can find more information about the configuration options here: https://github.com/kohsuke/winsw/blob/master/doc/xmlConfigFile.md
 Full example: https://github.com/kohsuke/winsw/blob/master/examples/sample-allOptions.xml
-->
<service>
  
  <!-- ID of the service. It should be unique across the Windows system-->
  <id>frpc-service</id>
  <!-- Display name of the service -->
  <name>frpc-service</name>
  <!-- Service description -->
  <description>frpc内网穿透客户端服务</description>
  
  <!-- Path to the executable, which should be started -->
  <executable>%BASE%\frpc.exe</executable>
  <arguments>-c frpc.toml</arguments>
  <!-- 标记为延迟启动 -->
  <!-- <delayedAutoStart>true</delayedAutoStart> -->

</service>

5、以管理员身份打开cmd,切到exe所在目录。执行如下命令:

// 注册服务
frpc-service.exe install

// 卸载服务
frpc-service.exe uninstall
最后修改:2024 年 06 月 17 日
如果觉得我的文章对你有用,请随意赞赏