Apachefoorumi.net
Raikasta ja ravitsevaa sielunruokaa.
@ECHO OFF
REM = VARIABLES - PLEASE EDIT ACCORDING TO YOUR OWN SETUP =
REM MAXDELAY: Waiting period after each successful test cycle. Default is 10 minutes ( 600 )
REM RECONDELAY: Waiting period after each failed test cycle, before next reconnect attempt. Default is 2 minutes ( 120 )
REM VPNNAME: The preconfigured name of the VPN connection to be monitored, can be found from your control panel
REM VPNUSER: Username to logon on to the preconfigured VPN connection
REM VPNPASS: Password for the username entered as VPNUSER.
REM VPNIP: The IP-address to ping when testing configured VPN.
REM VPNIP: Works best if this is another computer within the same VPN connected network.
REM PINGRESPONSE: The expected response from a successful PING
REM RASDIALRESPONSE: The expected response from RASDIAL after successful connection
REM NOTICE! The script was written for Windows 7, in Finnish!
REM NOTICE! For other languages, you will need to edit the expected keywords
REM NOTICE! from responses after PING and RASDIAL accordingly.
REM NOTICE! For English Win 7 you may use "Successfully" for RASDIALR
REM NOTICE! Use "Reply" for PING.
SET maxdelay=600
SET recondelay=120
SET vpnname=VPN-yhteys
SET vpnuser=Username
SET vpnpass=Password
SET vpnip=192.168.10.36
SET pingresponse=Vastaus
SET rasdialr=Suorittaminen
REM = ACTUAL TEST CYCLE, DO NOT EDIT BELOW THIS LINE =
CLS
REM Make sure the connection we are trying to monitor can actually be monitored.
REM Is it active at the moment?
REM If no active connection with the configured name can be found,
REM skip testing and move on to try and activate the connection
REM If active connection can be found, move on to testing the connection
:start
rasdial | find /I "%vpnname%" > nul
if errorlevel 1 goto vpndown
if errorlevel 0 goto pingtest
REM Ping the test IP-address, to make sure the connection is active and actually works.
REM If no response is received, move on to try and reactivate the connection.
REM If a successful response is received, skip reactivation and move on the wait for the next cycle.
:pingtest
ping %vpnip% -n 1 | find /I "%pingresponse%" >nul
if errorlevel 1 goto vpndown
if errorlevel 0 goto vpnup
REM If VPN connection was not found, was not active, or no response was received
REM for the test ping, close the active connection if there is any.
REM After closing the connection, reopen connection and try to logon again.
:vpndown
echo %time% VPN connection is not active, or not responding.
echo %time% Closing active VPN connections using the tunnel %vpnname%.
rasdial "%vpnname%" /d >nul
echo %time% Trying to reopen the tunnel %vpnname%.
rasdial "%vpnname%" "%vpnuser%" "%vpnpass%" | find /I "%rasdialr%" > nul
if errorlevel 1 (
echo %time% Connection could not be reopened. The host may be busy.
echo %time% Waiting for %recondelay% seconds before attempting again.
timeout /t %recondelay% /nobreak > NUL
goto start
) else (
echo %time% Connection succesfully reopened.
echo %time% Waiting for %maxdelay% seconds before running the next test cycle.
timeout /t %maxdelay% /nobreak > NUL
goto start
)
REM If VPN connection was found, and the test ping received a successful response, delay next test cycle.
:vpnup
echo %time% VPN connection is active and responding.
echo %time% Waiting for %maxdelay% seconds before running the next test cycle.
timeout /t %maxdelay% /nobreak > NUL
goto start
REM This script will run until interrupted by user, it will not terminate on it's own.
REM Written, tested and wholeheartedly abused daily By LexA since 2014
:endloop
goto start
Page created in 0.052 seconds with 24 queries.