Thursday, 3 July 2014

Click Download And Sleep Tight.....

John : Feeling sleepy....download complete 33%...still long way to go...shit man!! I could have started the download few hours back... Now who will shut this damn thing off..:(

Jeremiah : Is that a problem! huh! Can't you set the auto shutdown option in the download manager set to "Shut down when complete". That is simple!!

John : Aahaan!! Thanks man!! You are a genius!!

Stuart : Hey!! What if your internet connection fails? :P

Jeremiah John : Ooo !! Aaann...

Stuart : Do not worry guys, we have a solution here for this...along with Jeremiah's idea... Few days back I met an guy who wrote something to sort this thing....

REM Author : Sovan Misra
REM Created on : 9th Feb 2013
REM Purpose : To check if internet is connected or not, if connected okay, else shut down
REM Start execution
@echo off
REM goto main label to ping www.google.com
goto :MAIN
:MAIN
ECHO Checking connection, please wait...
PING -n 1 www.google.com|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESS
IF     ERRORLEVEL 1 goto :TRYAGAIN
:TRYAGAIN
ECHO FAILURE!
ECHO Let me try a bit more, please wait...
@echo off
PING -n 3 www.google.com|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESS2
IF     ERRORLEVEL 1 goto :TRYIP
:TRYIP
ECHO FAILURE!
ECHO Checking DNS...
ECHO Lets try by IP address...
@echo off
ping -n 1 216.239.37.99|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :SUCCESSDNS
IF     ERRORLEVEL 1 goto :TRYROUTER
:TRYROUTER
ECHO FAILURE!
ECHO Lets try pinging the router....
ping -n 2 192.168.100.1|find "Reply from " >NUL
IF NOT ERRORLEVEL 1 goto :ROUTERSUCCESS
IF     ERRORLEVEL 1 goto :NETDOWN
:ROUTERSUCCESS
ECHO It appears that you can reach the router, but internet is unreachable.
goto :FAILURE
:NETDOWN
ECHO FAILURE!
ECHO It appears that you having network issues, the router cannot be reached.
goto :FAILURE
:SUCCESSDNS
ECHO It appears that you are having DNS issues.
goto :FAILURE
:SUCCESS
ECHO You have an active Internet connection
ECHO Next checking will be done after 300 sec
timeout /T 300
goto :MAIN

:SUCCESS2
ECHO You have an active internet connection but some packet loss was detected.
ECHO Next checking will be done after 300 sec
timeout /T 300
goto :MAIN

:FAILURE
ECHO You do not have an active Internet connection
ECHO Computer is shutting down in 10 mins
timeout /T 600
goto :SHUTDOWN
goto :END
:SHUTDOWN
SHUTDOWN -S
goto :END

:END


Take a note pad -> copy and paste this -> save this file as "net_check.bat" -> Run it -> Go to bed..where ever the internet connection fails, it will wait for 600 seconds for connection to restore before shutting down the system

Make sure you have used Jeremiah's idea too....if connection remains firm this will help to shut down when download completes.

Hope will help you guys!!

No comments:

Post a Comment