[GH-ISSUE #3621] windows 怎么后台运行,不借用第三方工具 #2889

Closed
opened 2026-05-05 13:51:55 -06:00 by gitea-mirror · 12 comments
Owner

Originally created by @Yancy0220 on GitHub (Sep 18, 2023).
Original GitHub issue: https://github.com/fatedier/frp/issues/3621

Describe the feature request

windows 怎么后台运行,不借用第三方工具

Describe alternatives you've considered

No response

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @Yancy0220 on GitHub (Sep 18, 2023). Original GitHub issue: https://github.com/fatedier/frp/issues/3621 ### Describe the feature request windows 怎么后台运行,不借用第三方工具 ### Describe alternatives you've considered _No response_ ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [ ] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [ ] Others
gitea-mirror 2026-05-05 13:51:55 -06:00
Author
Owner

@Glucy-2 commented on GitHub (Sep 19, 2023):

计划任务

<!-- gh-comment-id:1724639111 --> @Glucy-2 commented on GitHub (Sep 19, 2023): 计划任务
Author
Owner

@aienuo commented on GitHub (Sep 19, 2023):

我现在是把他注册到服务里面,参考:https://gitee.com/xinlau/DocumentationAndTutorials/blob/master/Windows/FRP-Client.md

<!-- gh-comment-id:1724861506 --> @aienuo commented on GitHub (Sep 19, 2023): 我现在是把他注册到服务里面,参考:https://gitee.com/xinlau/DocumentationAndTutorials/blob/master/Windows/FRP-Client.md
Author
Owner

@Walkersifolia commented on GitHub (Oct 8, 2023):

简单点的写个vbs放在启动文件夹里就行了,Win+R打开运行,输入shell:startup,把vbs脚本放里面,就像这样
image

<!-- gh-comment-id:1752091126 --> @Walkersifolia commented on GitHub (Oct 8, 2023): 简单点的写个vbs放在启动文件夹里就行了,Win+R打开运行,输入shell:startup,把vbs脚本放里面,就像这样 ![image](https://github.com/fatedier/frp/assets/129571444/2f0a30e2-eeb8-438c-82f6-6d88cfb037e6)
Author
Owner

@Walkersifolia commented on GitHub (Oct 8, 2023):

然后就能看见了,开机自启动,并且没有cmd窗口
image

<!-- gh-comment-id:1752091489 --> @Walkersifolia commented on GitHub (Oct 8, 2023): 然后就能看见了,开机自启动,并且没有cmd窗口 ![image](https://github.com/fatedier/frp/assets/129571444/ac610e7f-afb8-457c-9f87-67015271b635)
Author
Owner

@cholau0 commented on GitHub (Oct 16, 2023):

vbs这个好!

<!-- gh-comment-id:1763683737 --> @cholau0 commented on GitHub (Oct 16, 2023): vbs这个好!
Author
Owner

@wzshuang commented on GitHub (Oct 17, 2023):

简单点的写个vbs放在启动文件夹里就行了,Win+R打开运行,输入shell:startup,把vbs脚本放里面,就像这样 image

求vbs脚本

<!-- gh-comment-id:1765540060 --> @wzshuang commented on GitHub (Oct 17, 2023): > 简单点的写个vbs放在启动文件夹里就行了,Win+R打开运行,输入shell:startup,把vbs脚本放里面,就像这样 ![image](https://user-images.githubusercontent.com/129571444/273459235-2f0a30e2-eeb8-438c-82f6-6d88cfb037e6.png) 求vbs脚本
Author
Owner

@Walkersifolia commented on GitHub (Oct 17, 2023):

求vbs脚本

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run chr(34) & "D:\frp.bat" & Chr(34), 0
Set WshShell = Nothing

frp.bat里就是正常的frp启动命令frpc -c D:/frp/frpc.ini

<!-- gh-comment-id:1766606188 --> @Walkersifolia commented on GitHub (Oct 17, 2023): > 求vbs脚本 ``` Set WshShell = CreateObject("WScript.Shell") WshShell.Run chr(34) & "D:\frp.bat" & Chr(34), 0 Set WshShell = Nothing ``` frp.bat里就是正常的frp启动命令`frpc -c D:/frp/frpc.ini`
Author
Owner

@Walkersifolia commented on GitHub (Oct 17, 2023):

求vbs脚本

路径记得自己改一下

<!-- gh-comment-id:1766607932 --> @Walkersifolia commented on GitHub (Oct 17, 2023): > 求vbs脚本 路径记得自己改一下
Author
Owner

@wzshuang commented on GitHub (Oct 17, 2023):

求vbs脚本

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run chr(34) & "D:\frp.bat" & Chr(34), 0
Set WshShell = Nothing

frp.bat里就是正常的frp启动命令frpc -c D:/frp/frpc.ini

收到,感谢

<!-- gh-comment-id:1766710950 --> @wzshuang commented on GitHub (Oct 17, 2023): > > 求vbs脚本 > > ``` > Set WshShell = CreateObject("WScript.Shell") > WshShell.Run chr(34) & "D:\frp.bat" & Chr(34), 0 > Set WshShell = Nothing > ``` > > frp.bat里就是正常的frp启动命令`frpc -c D:/frp/frpc.ini` 收到,感谢
Author
Owner

@Meta39 commented on GitHub (Oct 26, 2023):

最好还是用第三方工具WinSW把frpc做成服务放到服务里面。我试过写脚本放到shell:startup有时候不行!最稳妥还是用windows的服务!用米家智能WIFI插座 + 服务,现在很稳定!基本上想开机就开机,想关机就关机!
image

可以参考一下这篇文章《使用WinSW第三方工具设置开机启动》

<!-- gh-comment-id:1780784101 --> @Meta39 commented on GitHub (Oct 26, 2023): 最好还是用第三方工具WinSW把frpc做成服务放到服务里面。我试过写脚本放到shell:startup有时候不行!最稳妥还是用windows的服务!用米家智能WIFI插座 + 服务,现在很稳定!基本上想开机就开机,想关机就关机! ![image](https://github.com/fatedier/frp/assets/57950116/17ea3c03-a84e-4ba9-b1f2-3bc7e9e4f78f) [可以参考一下这篇文章《使用WinSW第三方工具设置开机启动》](https://blog.csdn.net/weixin_43933728/article/details/132783275)
Author
Owner

@github-actions[bot] commented on GitHub (Nov 26, 2023):

Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.

<!-- gh-comment-id:1826453342 --> @github-actions[bot] commented on GitHub (Nov 26, 2023): Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.
Author
Owner

@Xiaeer commented on GitHub (Mar 23, 2026):

Set shell = Wscript.CreateObject("WScript.Shell")

maxRetryCount = 3
retryDelay = 5000 ' 5秒

retryCount = 0
exitCode = -1

Do While retryCount < maxRetryCount And exitCode <> 0
    If retryCount > 0 Then
        Wscript.Sleep retryDelay
    End If
    
    retryCount = retryCount + 1
    
    ' Wscript.Echo "Running command: frpc.exe -c frpc.toml (Attempt " & retryCount & ")..."
    exitCode = shell.Run("frpc.exe -c frpc.toml", 0, False)
    
    If exitCode <> 0 Then
        ' Wscript.Echo "Command failed with exit code: " & exitCode
        ' Wscript.Echo "Retrying..."
    End If
Loop

If exitCode = 0 Then
    ' Wscript.Echo "Command executed successfully."
Else
    Wscript.Echo "Command execution failed after " & maxRetryCount & " attempts."
End If

个人觉得这个 vbs 脚本稍微好些,自带重试功能,因为我发现,vbs 自启 frpc 时,网卡没加载完毕时,frpc 进程会直接崩溃退出,loginFailExit = false 设置了都没用,一样崩溃退出。

<!-- gh-comment-id:4107614722 --> @Xiaeer commented on GitHub (Mar 23, 2026): ``` Set shell = Wscript.CreateObject("WScript.Shell") maxRetryCount = 3 retryDelay = 5000 ' 5秒 retryCount = 0 exitCode = -1 Do While retryCount < maxRetryCount And exitCode <> 0 If retryCount > 0 Then Wscript.Sleep retryDelay End If retryCount = retryCount + 1 ' Wscript.Echo "Running command: frpc.exe -c frpc.toml (Attempt " & retryCount & ")..." exitCode = shell.Run("frpc.exe -c frpc.toml", 0, False) If exitCode <> 0 Then ' Wscript.Echo "Command failed with exit code: " & exitCode ' Wscript.Echo "Retrying..." End If Loop If exitCode = 0 Then ' Wscript.Echo "Command executed successfully." Else Wscript.Echo "Command execution failed after " & maxRetryCount & " attempts." End If ``` 个人觉得这个 vbs 脚本稍微好些,自带重试功能,因为我发现,vbs 自启 frpc 时,网卡没加载完毕时,frpc 进程会直接崩溃退出,`loginFailExit = false` 设置了都没用,一样崩溃退出。
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#2889
No description provided.