This page has been robot translated, sorry for typos if any. Original content here.

Script pingovalka to maintain Gprs-connection

Скрипт-пинговалка для поддержания Gprs-соединения

Quite often, operators (and providers) offer cheap Internet - or even provide anlim.

But we are not all like people, just can not be happy.

Often the connection is broken or "plugged" "stuck" (when the connection is not broken, but the data does not go).

Anyone who encounters this problem will be helped by a simple pingalo script.

Its meaning: the address is periodically pinged. In the absence of ping (when the channel is “stuck” or broken), reconnection occurs.

By running this script, you can be sure that the connection is working.

Procedure

1. Create a cmd file (for example, pinger.cmd) in notepad with the following contents:

 @echo off
 echo% date%% time% --- STARTED --- >> pinger.log
 set Try = 1

 rem All settings are in this block.

 rem connection name
 set DialName = Life
 rem login
 set Login = Login
 rem Password
 set Pass = Password
 rem ping timeout in ms
 set TimeOut = 10000
 rem number of ping attempts
 set MaxPing = 5
 rem pause in s
 set Pause = 30
 rem ping host address
 set host = ya.ru
 rem your phone number
 set PhoneNum = 80631234567

 : start
 echo.
 echo start ping
 ping% host% -n 1 -w% TimeOut%
 if errorlevel = 1 goto bad
 goto ok

 : ping
 echo.
 ping% host% -n 1 -w% TimeOut%
 if not errorlevel = 1 goto ok
 set / a Try =% Try% + 1
 if% try% geq% maxping% goto bad
 goto ping

 : ok
 echo.
 echo ALL RIGHT
 goto end

 : bad
 set / a Try = 1
 echo.
 echo BAD CONNECT
 echo% date%% time% -!  Trouble, reconnect! - >> pinger.log
 rasdial% DialName% / disconnect
 rasdial% DialName% / phone:% PhoneNum%
 rasdial% DialName%% Login%% Pass%
 if errorlevel = 1 goto bad
 goto ping

 : end
 set / a Try = 1
 echo.
 choice / C: PRDE / T: P, 30 / N Pause 30 seconds.  [P] ing [R] econnect [D] isconnect [E] xit?
 rem echo.
 rem echo.
 goto% ERRORLEVEL%
 :one
 goto ping
 : 2
 goto bad
 : 3
 rasdial% DialName% / disconnect
 :four
 echo% date%% time% == Exit script == >> pinger.log

In this file you need to replace MANDATORY :

  • connection name (set DialName = Life) [see the name: Start - Settings - Network connections - the name of your connection]
  • login / password (set Login = Login set Pass = Password) - if it is required to establish a connection

In this file, you need to replace (if desired):

  • host address that is pinged (set host = ya.ru)
  • ping timeout (set TimeOut = 10000)
  • the number of ping attempts (set MaxPing = 5) after which there will be a reconnection
  • connection check interval (set Pause = 30)

2. Next to pinger.cmd put "choice.com" from the archive choise.rar.

3. We start and enjoy life - pingovalka will establish a connection and will maintain it in working condition.

!!! A similar script "pinger" for Linux to maintain the dedicated pinger.zip.

choise.rar (2.88 kilobytes) choise.rar (2.88 kilobytes) choise.rar (2.88 kilobytes) Virus Free by KAV
pinger.zip (684 bytes) pinger.zip (684 bytes) pinger.zip (684 bytes) Virus Free by KAV