Using a .bat file to automatically reconnect a Cisco VPN to connection failure

I would like to help create an automatic BAT script that will reconnect my Cisco VPN Client session in the event of an Internet disconnect.

There are two commands: command 1for connecting and command 2for disconnecting.

To monitor the connection, I would like to use ICMP (Like 5 failed pings), and if you work in a VPN, continue to forward data. If you are not using command 2to disconnect the VPN session and try to reconnect.

If possible, I would like it to loop so that it automatically connects every time WAN Link breaks.

team 1 . Client program:C:\Program Files (x86)\Cisco Systems\VPN

start vpnclient connect rcx user TESTE pwd TESTE stdin

team 2 . Client program:C:\Program Files (x86)\Cisco Systems\VPN

vpnclient disconnect

.

+4
1

ping IP- , 10 , vpnclient 10 , .

30- .

timeout Vista .

@echo off
cd /d "C:\Program Files (x86)\Cisco Systems\VPN"
:loop
    echo testing IP address
    ping 123.456.78.90 >nul || (
       echo ping failure - disconnecting
       vpnclient disconnect
          timeout /t 10 /nobreak
       echo reconnecting
       start vpnclient connect rcx user TESTE pwd TESTE stdin
          timeout /t 10 /nobreak
   )
timeout /t 30 /nobreak
goto :loop
+9

Source: https://habr.com/ru/post/1529407/


All Articles