Saturday, September 22, 2012

My ISP really sucks !

[Update] Attaching real files. Add your login id and password in login.vbs. Download


I have been using this service (hathway.com) for part 2 years and for last few months I was shocked to see that in the name of security my ISP has scheduled internet connection reset twice – thrice a day. To start the service again I need to login to the ISP web portal. For your information my plan so called “unlimited plan”.
In simple words if you download a lot, specially through torrents, your downloading will tend to go on entire night  or may be days – UNMONITORED. Since this resetting business started, my internet connection resets somewhere between 11:00 PM to 3:30 AM and there is no way I can keep monitoring the connection so that I can login as soon as it disconnects to ensure my downloading.
I had to do something about it. Programmer inside me woke up again. I pulled up my sleeves – got a cup of coffee, and went back to see for solution.
Quite easily an algorithm was designed-
1.  Loop
2. Keep monitoring the internet connection
3. If internet connection is working go to step 1 else step 3
3. as soon as internet connection breaks open internet explorer. Enter username and password.
4. Go to step 1
So first I need to write a script for the step 3. I used VB Script. Below is the code. What it does is open internet explorer then navigate to the ISP web portal and then try to figure out the element ID where I need to enter the username and password. Just save the script as (lets say) “login.vbs”
   1: DIM IE

   2: DIM ipf

   3:  

   4: Set IE = CreateObject("internetexplorer.Application")

   5: IE.navigate "http://203.212.193.59/bsp/startportal.do?CPURL=http://203.212.193.59/"

   6: IE.Visible = True

   7:  

   8: While IE.Busy

   9:      WScript.Sleep 50

  10: Wend

  11:  

  12: Set ipf1 = IE.document.getElementByID("username")

  13:  ipf1.Value = "my username" 'fill in the text box

  14: Set ipf2 = IE.document.getElementByID("password")

  15:  ipf2.Value = "My password" '
fill in the text box
  16: Set ipf3 = IE.document.all.Submit

  17:  ipf3.Click    'click the submit button

  18: '
IE.Quit


If you run this VB script while you are already logged in then you will get an error that element id not found.

                                                            image

Why ?

             Because you ISP portal will redirect the script to the welcome page where the element id is not present.

Hence if I schedule this script to run over and over then I will get the error message. To solve this I need to write a separate batch file which contains logic steps 1,2, &3 of algorithm.

Below is the batch file.



   1: :begin

   2: @ECHO OFF

   3: setlocal

   4:  

   5: SET UNKN="Unknown host"

   6: SET FAIL="Lost = 4"

   7: SET RECD="Received = 4"

   8:  

   9: FOR /F "tokens=1,2,3,4 delims=/ " %%I IN ('DATE /T') DO SET date1=%%J/%%K/%%L

  10: FOR /F "tokens=1,2 delims=: " %%I IN ('TIME /T') DO SET time1=%%I:%%J

  11:  

  12: ping google.com | FIND /I %UNKN% >NUL

  13: IF NOT ERRORLEVEL 1 ECHO [%date1% %time%]  unknown >>.\pingstat.log & GOTO :END

  14:  

  15: ping google.com | FIND /I %FAIL% >NUL

  16: IF NOT ERRORLEVEL 1 ECHO [%date1% %time%]  failure >>.\pingstat.log & cscript .\login.vbs & GOTO :END

  17:  

  18: ping google.com | FIND /I %RECD% >NUL

  19: IF NOT ERRORLEVEL 1 ECHO [%date1% %time%]  success >>pingstat.log & GOTO :END

  20:  

  21: endlocal

  22: :END



Lets save this file as login.bat

What it does is – It pings google.com. If it pings then end of file and if not then call the login.vbs file (saved in same folder). It also save a entry with “Success” or “Failure” in a text file with the name “Pingstat.txt” (I used it for testing)

Now all my steps are completed from the algorithm I devised. Only thing left is scheduling this script. All I need to do is schedule the batch file thorough windows task scheduler.

And YAY ! I am done.

Now my downloading goes uninterrupted and unmonitored.




2 comments:

  1. How do i save this?

    Can You send it to my email?

    ReplyDelete
  2. You can directly download it from this link http://dl.dropbox.com/u/45448074/login.rar

    ReplyDelete