Reputation: 1
I am using a batch file for shrewsoft VPN connect-disconnect, my requirements are 1. I am doing a ping test, if ping is failed (internet failure or disconnection issues) then VPN should disconnect and the moment the Internet is ON and ping starts, VPN should connect automatically. So I am looking for an infinite ping loop which will connect or disconnect VPN
I am using this batch but when internet is off (connection failure) VPN disconnects, but I want code to reconnect the VPN once internet connection is reinstated.
@echo off start /min "vpn" "C:\Program Files\ShrewSoft\VPN Client\ipsecc.exe" -r "testVPN.vpn" -u username -p password -a :loop echo testing IP address ping 121.244.116.222 >nul || ( echo ping failure - disconnecting taskkill /T /F /IM "ipsecc.exe"
) timeout /t 30 /nobreak goto :loop
Upvotes: 0
Views: 1644
Reputation: 1
try using "expect" as described in https://sakhnik.com/2016/11/21/automatic-vpn.html
Maybe you can adopt this.
Upvotes: 0
Reputation: 3363
I've built and open sourced an app to do exactly that, Check it out at https://github.com/CamW/shrew-reconnect if you're interested. You can build from code or just download the installer.
Hope that helps.
Upvotes: 0