Guest User

Inet Keeper - Keeps you connected to the Internet

a guest
Apr 19th, 2014
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.50 KB | None | 0 0
  1. @ECHO OFF
  2.  
  3. ::VARIABLES
  4.  
  5. ::First two words of a (succeful) ping response
  6. SET _ping_reply=Resposta de
  7.  
  8. ::Name of the internet connection
  9. SET _conn_name=Oi 3G
  10.  
  11. ::Time between checks (in seconds)
  12. SET _time=60
  13.  
  14. ::Directory to save history
  15. SET _hist_dir=D:\ik_hist.txt
  16.  
  17.  
  18.  
  19. TITLE Inet Keeper
  20.  
  21. ECHO ---------------------------------------------------
  22. ECHO  Inet Keeper - Keeps you connected to the internet
  23. ECHO ------------------------------------- by JackS ----
  24. ECHO.
  25. ECHO - Ping reply start: "%_ping_reply%"
  26. ECHO - Internet connection name: "%_conn_name%"
  27. ECHO - History directory: "%_hist_dir%"
  28. ECHO - Time between checks: %_time% seconds
  29. ECHO.
  30. ECHO -------------------------------------------
  31.  
  32. GOTO :CHECKCONNECTION
  33.  
  34. :CHECKCONNECTION
  35. ECHO  @ @ ^| Checking connection, please wait...
  36. PING -n 1 www.google.com|find "%_ping_reply%" >NUL
  37. IF NOT ERRORLEVEL 1 goto :SUCCESS
  38. IF     ERRORLEVEL 1 goto :TRYRECONNECT
  39.  
  40. :SUCCESS
  41. ECHO   U  ^| You are connected to the internet.
  42. ECHO  \_/ ^| Waiting %_time% seconds to check again...
  43. PING -n %_time% 127.0.0.1>nul
  44. ECHO -----+-------------------------------------
  45. GOTO :CHECKCONNECTION
  46.  
  47. :TRYRECONNECT
  48. ECHO ----- >> "%_hist_dir%"
  49. date /T >> "%_hist_dir%"
  50. time /T >> "%_hist_dir%"
  51. ECHO Ping failure. Trying to reconnect. >> "%_hist_dir%"
  52. ECHO   U  ^| Ping failure!
  53. ECHO  ~~~ ^| Trying to reconnect to %_conn_name%...
  54. RASDIAL "%_conn_name%" >> "%_hist_dir%"
  55. ECHO -----+-------------------------------------
  56. PING -n 5 127.0.0.1>nul
  57. GOTO :CHECKCONNECTION
Advertisement
Add Comment
Please, Sign In to add comment