- 新建运行frpc的脚本frpc_start.vbs
set ws=WScript.CreateObject("WScript.Shell")
ws.Run "D:\frp\frpc.exe -c D:\frp\frpc.ini",0
- 新建检测wifi和frpc运行的脚本,先检测wifi是否连接,如果连接了,就启动frpc_start.vbs脚本
@echo off
set wifi_name=704
set log_file=D:\frp\frpc_monitor.log
set try_cnt=1
set frpc_start=D:\frp\frpc_start.vbs
echo [%date% %time%] Start connect wifi:%wifi_name% >>%log_file%
rem 主循环
:mainloop
(netsh WLAN show interfaces | findStr %wifi_name% >nul && (
echo [%date% %time%] wifi:%wifi_name% already connected>>%log_file%
tasklist | find /i "frpc.exe" && echo [%date% %time%] frpc already running >> %log_file% || cscript %frpc_start% >>%log_file%
)) || (
set /a try_cnt+=1
echo [%date% %time%] try to connect...[%try_cnt%]
echo [%date% %time%] try to connect...[%try_cnt%] >>%log_file%
netsh wlan connect ssid=%wifi_name% name=%wifi_name% >>%log_file%
)
choice /t 600 /d y /n >nul
goto mainloop
- 在开始启动文件夹下,新建frpc_monitor.vbs脚本,开机自运行
set ws=WScript.CreateObject("WScript.Shell")
ws.Run "D:\frp\frpc_monitor.bat /start",0